@@ -3,21 +3,6 @@ use core::f32::consts;
33
44use super :: { assert_approx_eq, assert_biteq} ;
55
6- /// Smallest number
7- const TINY_BITS : u32 = 0x1 ;
8-
9- /// Next smallest number
10- const TINY_UP_BITS : u32 = 0x2 ;
11-
12- /// Exponent = 0b11...10, Sifnificand 0b1111..10. Min val > 0
13- const MAX_DOWN_BITS : u32 = 0x7f7f_fffe ;
14-
15- /// Zeroed exponent, full significant
16- const LARGEST_SUBNORMAL_BITS : u32 = 0x007f_ffff ;
17-
18- /// Exponent = 0b1, zeroed significand
19- const SMALLEST_NORMAL_BITS : u32 = 0x0080_0000 ;
20-
216/// First pattern over the mantissa
227const NAN_MASK1 : u32 = 0x002a_aaaa ;
238
@@ -29,37 +14,6 @@ const NAN_MASK2: u32 = 0x0055_5555;
2914/// They serve as a way to get an idea of the real precision of floating point operations on different platforms.
3015const APPROX_DELTA : f32 = if cfg ! ( miri) { 1e-4 } else { 1e-6 } ;
3116
32- #[ test]
33- fn test_next_down ( ) {
34- let tiny = f32:: from_bits ( TINY_BITS ) ;
35- let tiny_up = f32:: from_bits ( TINY_UP_BITS ) ;
36- let max_down = f32:: from_bits ( MAX_DOWN_BITS ) ;
37- let largest_subnormal = f32:: from_bits ( LARGEST_SUBNORMAL_BITS ) ;
38- let smallest_normal = f32:: from_bits ( SMALLEST_NORMAL_BITS ) ;
39- assert_biteq ! ( f32 :: NEG_INFINITY . next_down( ) , f32 :: NEG_INFINITY ) ;
40- assert_biteq ! ( f32 :: MIN . next_down( ) , f32 :: NEG_INFINITY ) ;
41- assert_biteq ! ( ( -max_down) . next_down( ) , f32 :: MIN ) ;
42- assert_biteq ! ( ( -1.0f32 ) . next_down( ) , -1.0 - f32 :: EPSILON ) ;
43- assert_biteq ! ( ( -largest_subnormal) . next_down( ) , -smallest_normal) ;
44- assert_biteq ! ( ( -tiny) . next_down( ) , -tiny_up) ;
45- assert_biteq ! ( ( -0.0f32 ) . next_down( ) , -tiny) ;
46- assert_biteq ! ( ( 0.0f32 ) . next_down( ) , -tiny) ;
47- assert_biteq ! ( tiny. next_down( ) , 0.0f32 ) ;
48- assert_biteq ! ( tiny_up. next_down( ) , tiny) ;
49- assert_biteq ! ( smallest_normal. next_down( ) , largest_subnormal) ;
50- assert_biteq ! ( ( 1.0 + f32 :: EPSILON ) . next_down( ) , 1.0f32 ) ;
51- assert_biteq ! ( f32 :: MAX . next_down( ) , max_down) ;
52- assert_biteq ! ( f32 :: INFINITY . next_down( ) , f32 :: MAX ) ;
53-
54- // Check that NaNs roundtrip.
55- let nan0 = f32:: NAN ;
56- let nan1 = f32:: from_bits ( f32:: NAN . to_bits ( ) ^ NAN_MASK1 ) ;
57- let nan2 = f32:: from_bits ( f32:: NAN . to_bits ( ) ^ NAN_MASK2 ) ;
58- assert_biteq ! ( nan0. next_down( ) , nan0) ;
59- assert_biteq ! ( nan1. next_down( ) , nan1) ;
60- assert_biteq ! ( nan2. next_down( ) , nan2) ;
61- }
62-
6317// FIXME(#140515): mingw has an incorrect fma https://sourceforge.net/p/mingw-w64/bugs/848/
6418#[ cfg_attr( all( target_os = "windows" , target_env = "gnu" , not( target_abi = "llvm" ) ) , ignore) ]
6519#[ test]
0 commit comments