@@ -46,14 +46,15 @@ fn f32() {
46
46
47
47
// Check that NaNs roundtrip their bits regardless of signalingness
48
48
// 0xA is 0b1010; 0x5 is 0b0101 -- so these two together clobbers all the mantissa bits
49
- const MASKED_NAN1 : u32 = f32:: NAN . to_bits ( ) ^ 0x002A_AAAA ;
50
- const MASKED_NAN2 : u32 = f32:: NAN . to_bits ( ) ^ 0x0055_5555 ;
49
+ // NOTE: These names assume `f{BITS}::NAN` is a quiet NAN and IEEE754-2008's NaN rules apply!
50
+ const QUIET_NAN : u32 = f32:: NAN . to_bits ( ) ^ 0x002A_AAAA ;
51
+ const SIGNALING_NAN : u32 = f32:: NAN . to_bits ( ) ^ 0x0055_5555 ;
51
52
52
- const_assert ! ( f32 :: from_bits( MASKED_NAN1 ) . is_nan( ) ) ;
53
- const_assert ! ( f32 :: from_bits( MASKED_NAN2 ) . is_nan( ) ) ;
54
- const_assert ! ( f32 :: from_bits( MASKED_NAN1 ) . to_bits( ) , MASKED_NAN1 ) ;
53
+ const_assert ! ( f32 :: from_bits( QUIET_NAN ) . is_nan( ) ) ;
54
+ const_assert ! ( f32 :: from_bits( SIGNALING_NAN ) . is_nan( ) ) ;
55
+ const_assert ! ( f32 :: from_bits( QUIET_NAN ) . to_bits( ) , QUIET_NAN ) ;
55
56
if !has_broken_floats ( ) {
56
- const_assert ! ( f32 :: from_bits( MASKED_NAN2 ) . to_bits( ) , MASKED_NAN2 ) ;
57
+ const_assert ! ( f32 :: from_bits( SIGNALING_NAN ) . to_bits( ) , SIGNALING_NAN ) ;
57
58
}
58
59
}
59
60
@@ -75,14 +76,15 @@ fn f64() {
75
76
76
77
// Check that NaNs roundtrip their bits regardless of signalingness
77
78
// 0xA is 0b1010; 0x5 is 0b0101 -- so these two together clobbers all the mantissa bits
78
- const MASKED_NAN1 : u64 = f64:: NAN . to_bits ( ) ^ 0x000A_AAAA_AAAA_AAAA ;
79
- const MASKED_NAN2 : u64 = f64:: NAN . to_bits ( ) ^ 0x0005_5555_5555_5555 ;
79
+ // NOTE: These names assume `f{BITS}::NAN` is a quiet NAN and IEEE754-2008's NaN rules apply!
80
+ const QUIET_NAN : u64 = f64:: NAN . to_bits ( ) ^ 0x0005_5555_5555_5555 ;
81
+ const SIGNALING_NAN : u64 = f64:: NAN . to_bits ( ) ^ 0x000A_AAAA_AAAA_AAAA ;
80
82
81
- const_assert ! ( f64 :: from_bits( MASKED_NAN1 ) . is_nan( ) ) ;
82
- const_assert ! ( f64 :: from_bits( MASKED_NAN2 ) . is_nan( ) ) ;
83
- const_assert ! ( f64 :: from_bits( MASKED_NAN1 ) . to_bits( ) , MASKED_NAN1 ) ;
83
+ const_assert ! ( f64 :: from_bits( QUIET_NAN ) . is_nan( ) ) ;
84
+ const_assert ! ( f64 :: from_bits( SIGNALING_NAN ) . is_nan( ) ) ;
85
+ const_assert ! ( f64 :: from_bits( QUIET_NAN ) . to_bits( ) , QUIET_NAN ) ;
84
86
if !has_broken_floats ( ) {
85
- const_assert ! ( f64 :: from_bits( MASKED_NAN2 ) . to_bits( ) , MASKED_NAN2 ) ;
87
+ const_assert ! ( f64 :: from_bits( SIGNALING_NAN ) . to_bits( ) , SIGNALING_NAN ) ;
86
88
}
87
89
}
88
90
0 commit comments