@@ -91,6 +91,29 @@ FloatingPoint.test("Float/IntegerLiteralConvertible") {
91
91
expectEqual(negativeOne(), -1.0 as Float)
92
92
}
93
93
94
+ FloatingPoint.test("Float/FloatLiteralConvertible") {
95
+ let x: Float = -0.0
96
+ expectBitwiseEqual(bitPattern: 0x8000_0000, x)
97
+ }
98
+
99
+ FloatingPoint.test("Float/staticProperties") {
100
+ typealias Ty = Float
101
+ // From the FloatingPoint protocol.
102
+ expectEqual(2, Ty.radix)
103
+ expectBitwiseEqual(bitPattern: 0x7fc0_0000, Ty.nan)
104
+ expectBitwiseEqual(bitPattern: 0x7fa0_0000, Ty.signalingNaN)
105
+ expectBitwiseEqual(bitPattern: 0x7f80_0000, Ty.infinity)
106
+ expectBitwiseEqual(0x1.ffff_fe__p127, Ty.greatestFiniteMagnitude)
107
+ expectBitwiseEqual(0x1.921f_b6__p1, Ty.pi)
108
+ expectBitwiseEqual(0x1.0p-23, Ty.ulpOfOne)
109
+ expectBitwiseEqual(0x1.0p-126, Ty.leastNormalMagnitude)
110
+ expectBitwiseEqual(0x1.0p-149, Ty.leastNonzeroMagnitude)
111
+
112
+ // From the BinaryFloatingPoint protocol.
113
+ expectEqual(8, Ty.exponentBitCount)
114
+ expectEqual(23, Ty.significandBitCount)
115
+ }
116
+
94
117
// Tests the float and int conversions work correctly. Each case is special.
95
118
FloatingPoint.test("Float/UInt8") {
96
119
expectEqual(UInt8.min, UInt8(Float(UInt8.min)))
@@ -141,6 +164,29 @@ FloatingPoint.test("Double/IntegerLiteralConvertible") {
141
164
expectEqual(negativeOne(), -1.0 as Double)
142
165
}
143
166
167
+ FloatingPoint.test("Double/FloatLiteralConvertible") {
168
+ let x: Double = -0.0
169
+ expectBitwiseEqual(bitPattern: 0x8000_0000_0000_0000, x)
170
+ }
171
+
172
+ FloatingPoint.test("Double/staticProperties") {
173
+ typealias Ty = Double
174
+ // From the FloatingPoint protocol.
175
+ expectEqual(2, Ty.radix)
176
+ expectBitwiseEqual(bitPattern: 0x7ff8_0000_0000_0000, Ty.nan)
177
+ expectBitwiseEqual(bitPattern: 0x7ff4_0000_0000_0000, Ty.signalingNaN)
178
+ expectBitwiseEqual(bitPattern: 0x7ff0_0000_0000_0000, Ty.infinity)
179
+ expectBitwiseEqual(0x1.ffff_ffff_ffff_f__p1023, Ty.greatestFiniteMagnitude)
180
+ expectBitwiseEqual(0x1.921f_b544_42d1_8__p1, Ty.pi)
181
+ expectBitwiseEqual(0x1.0p-52, Ty.ulpOfOne)
182
+ expectBitwiseEqual(0x1.0p-1022, Ty.leastNormalMagnitude)
183
+ expectBitwiseEqual(0x1.0p-1074, Ty.leastNonzeroMagnitude)
184
+
185
+ // From the BinaryFloatingPoint protocol.
186
+ expectEqual(11, Ty.exponentBitCount)
187
+ expectEqual(52, Ty.significandBitCount)
188
+ }
189
+
144
190
FloatingPoint.test("Double/UInt8") {
145
191
expectEqual(UInt8.min, UInt8(Double(UInt8.min)))
146
192
expectEqual(UInt8.max, UInt8(Double(UInt8.max)))
@@ -238,6 +284,29 @@ FloatingPoint.test("Float80/IntegerLiteralConvertible") {
238
284
expectEqual(negativeOne(), -1.0 as Float80)
239
285
}
240
286
287
+ FloatingPoint.test("Float80/FloatLiteralConvertible") {
288
+ let x: Float80 = -0.0
289
+ expectBitwiseEqual(bitPattern: Float80Bits(0x8000, 0), x)
290
+ }
291
+
292
+ FloatingPoint.test("Float80/staticProperties") {
293
+ typealias Ty = Double
294
+ // From the FloatingPoint protocol.
295
+ expectEqual(2, Ty.radix)
296
+ expectBitwiseEqual(bitPattern: 0x7ff8_0000_0000_0000, Ty.nan)
297
+ expectBitwiseEqual(bitPattern: 0x7ff4_0000_0000_0000, Ty.signalingNaN)
298
+ expectBitwiseEqual(bitPattern: 0x7ff0_0000_0000_0000, Ty.infinity)
299
+ expectBitwiseEqual(0x1.ffff_ffff_ffff_f__p1023, Ty.greatestFiniteMagnitude)
300
+ expectBitwiseEqual(0x1.921f_b544_42d1_8__p1, Ty.pi)
301
+ expectBitwiseEqual(0x1.0p-52, Ty.ulpOfOne)
302
+ expectBitwiseEqual(0x1.0p-1022, Ty.leastNormalMagnitude)
303
+ expectBitwiseEqual(0x1.0p-1074, Ty.leastNonzeroMagnitude)
304
+
305
+ // From the BinaryFloatingPoint protocol.
306
+ expectEqual(11, Ty.exponentBitCount)
307
+ expectEqual(52, Ty.significandBitCount)
308
+ }
309
+
241
310
FloatingPoint.test("Float80/HashValueZero") {
242
311
let zero: Float80 = getFloat80(0.0)
243
312
let negativeZero: Float80 = getFloat80(-0.0)
0 commit comments