@@ -32,7 +32,7 @@ mod int_to_float {
3232 /// Usually 1 is subtracted from this function's result, so that a mantissa with the implicit
3333 /// bit set can be added back later.
3434 fn exp < I : Int , F : Float < Int : CastFrom < u32 > > > ( n : u32 ) -> F :: Int {
35- F :: Int :: cast_from ( F :: EXPONENT_BIAS - 1 + I :: BITS - n)
35+ F :: Int :: cast_from ( F :: EXP_BIAS - 1 + I :: BITS - n)
3636 }
3737
3838 /// Adjust a mantissa with dropped bits to perform correct rounding.
@@ -42,7 +42,7 @@ mod int_to_float {
4242 fn m_adj < F : Float > ( m_base : F :: Int , dropped_bits : F :: Int ) -> F :: Int {
4343 // Branchlessly extract a `1` if rounding up should happen, 0 otherwise
4444 // This accounts for rounding to even.
45- let adj = ( dropped_bits - ( dropped_bits >> ( F :: BITS - 1 ) & !m_base) ) >> ( F :: BITS - 1 ) ;
45+ let adj = ( dropped_bits - ( ( dropped_bits >> ( F :: BITS - 1 ) ) & !m_base) ) >> ( F :: BITS - 1 ) ;
4646
4747 // Add one when we need to round up. Break ties to even.
4848 m_base + adj
@@ -54,17 +54,17 @@ mod int_to_float {
5454 /// value to cancel it out.
5555 fn repr < F : Float > ( e : F :: Int , m : F :: Int ) -> F :: Int {
5656 // + rather than | so the mantissa can overflow into the exponent
57- ( e << F :: SIGNIFICAND_BITS ) + m
57+ ( e << F :: SIG_BITS ) + m
5858 }
5959
6060 /// Shift distance from a left-aligned integer to a smaller float.
6161 fn shift_f_lt_i < I : Int , F : Float > ( ) -> u32 {
62- ( I :: BITS - F :: BITS ) + F :: EXPONENT_BITS
62+ ( I :: BITS - F :: BITS ) + F :: EXP_BITS
6363 }
6464
6565 /// Shift distance from an integer with `n` leading zeros to a smaller float.
6666 fn shift_f_gt_i < I : Int , F : Float > ( n : u32 ) -> u32 {
67- F :: SIGNIFICAND_BITS - I :: BITS + 1 + n
67+ F :: SIG_BITS - I :: BITS + 1 + n
6868 }
6969
7070 /// Perform a signed operation as unsigned, then add the sign back.
@@ -85,9 +85,9 @@ mod int_to_float {
8585 }
8686 let n = i. leading_zeros ( ) ;
8787 // Mantissa with implicit bit set (significant bits)
88- let m_base = ( i << n) >> f32:: EXPONENT_BITS ;
88+ let m_base = ( i << n) >> f32:: EXP_BITS ;
8989 // Bits that will be dropped (insignificant bits)
90- let adj = ( i << n) << ( f32:: SIGNIFICAND_BITS + 1 ) ;
90+ let adj = ( i << n) << ( f32:: SIG_BITS + 1 ) ;
9191 let m = m_adj :: < f32 > ( m_base, adj) ;
9292 let e = exp :: < u32 , f32 > ( n) - 1 ;
9393 repr :: < f32 > ( e, m)
@@ -116,7 +116,7 @@ mod int_to_float {
116116 let m = ( i as u64 ) << ( shift_f_gt_i :: < u32 , f128 > ( n) - 64 ) ;
117117 let e = exp :: < u32 , f128 > ( n) as u64 - 1 ;
118118 // High 64 bits of f128 representation.
119- let h = ( e << ( f128:: SIGNIFICAND_BITS - 64 ) ) + m;
119+ let h = ( e << ( f128:: SIG_BITS - 64 ) ) + m;
120120
121121 // Shift back to the high bits, the rest of the mantissa will always be 0.
122122 ( h as u128 ) << 64
@@ -128,8 +128,8 @@ mod int_to_float {
128128 // Mantissa with implicit bit set
129129 let m_base: u32 = ( i_m >> shift_f_lt_i :: < u64 , f32 > ( ) ) as u32 ;
130130 // The entire lower half of `i` will be truncated (masked portion), plus the
131- // next `EXPONENT_BITS ` bits.
132- let adj = ( i_m >> f32:: EXPONENT_BITS | i_m & 0xFFFF ) as u32 ;
131+ // next `EXP_BITS ` bits.
132+ let adj = ( ( i_m >> f32:: EXP_BITS ) | i_m & 0xFFFF ) as u32 ;
133133 let m = m_adj :: < f32 > ( m_base, adj) ;
134134 let e = if i == 0 { 0 } else { exp :: < u64 , f32 > ( n) - 1 } ;
135135 repr :: < f32 > ( e, m)
@@ -141,8 +141,8 @@ mod int_to_float {
141141 }
142142 let n = i. leading_zeros ( ) ;
143143 // Mantissa with implicit bit set
144- let m_base = ( i << n) >> f64:: EXPONENT_BITS ;
145- let adj = ( i << n) << ( f64:: SIGNIFICAND_BITS + 1 ) ;
144+ let m_base = ( i << n) >> f64:: EXP_BITS ;
145+ let adj = ( i << n) << ( f64:: SIG_BITS + 1 ) ;
146146 let m = m_adj :: < f64 > ( m_base, adj) ;
147147 let e = exp :: < u64 , f64 > ( n) - 1 ;
148148 repr :: < f64 > ( e, m)
@@ -167,7 +167,7 @@ mod int_to_float {
167167
168168 // Within the upper `F::BITS`, everything except for the signifcand
169169 // gets truncated
170- let d1: u32 = ( i_m >> ( u128:: BITS - f32:: BITS - f32:: SIGNIFICAND_BITS - 1 ) ) . cast ( ) ;
170+ let d1: u32 = ( i_m >> ( u128:: BITS - f32:: BITS - f32:: SIG_BITS - 1 ) ) . cast ( ) ;
171171
172172 // The entire rest of `i_m` gets truncated. Zero the upper `F::BITS` then just
173173 // check if it is nonzero.
@@ -186,8 +186,8 @@ mod int_to_float {
186186 // Mantissa with implicit bit set
187187 let m_base: u64 = ( i_m >> shift_f_lt_i :: < u128 , f64 > ( ) ) as u64 ;
188188 // The entire lower half of `i` will be truncated (masked portion), plus the
189- // next `EXPONENT_BITS ` bits.
190- let adj = ( i_m >> f64:: EXPONENT_BITS | i_m & 0xFFFF_FFFF ) as u64 ;
189+ // next `EXP_BITS ` bits.
190+ let adj = ( ( i_m >> f64:: EXP_BITS ) | i_m & 0xFFFF_FFFF ) as u64 ;
191191 let m = m_adj :: < f64 > ( m_base, adj) ;
192192 let e = if i == 0 { 0 } else { exp :: < u128 , f64 > ( n) - 1 } ;
193193 repr :: < f64 > ( e, m)
@@ -200,8 +200,8 @@ mod int_to_float {
200200 }
201201 let n = i. leading_zeros ( ) ;
202202 // Mantissa with implicit bit set
203- let m_base = ( i << n) >> f128:: EXPONENT_BITS ;
204- let adj = ( i << n) << ( f128:: SIGNIFICAND_BITS + 1 ) ;
203+ let m_base = ( i << n) >> f128:: EXP_BITS ;
204+ let adj = ( i << n) << ( f128:: SIG_BITS + 1 ) ;
205205 let m = m_adj :: < f128 > ( m_base, adj) ;
206206 let e = exp :: < u128 , f128 > ( n) - 1 ;
207207 repr :: < f128 > ( e, m)
@@ -362,29 +362,29 @@ where
362362 F :: Int : CastFrom < u32 > ,
363363 u32 : CastFrom < F :: Int > ,
364364{
365- let int_max_exp = F :: EXPONENT_BIAS + I :: MAX . ilog2 ( ) + 1 ;
366- let foobar = F :: EXPONENT_BIAS + I :: UnsignedInt :: BITS - 1 ;
365+ let int_max_exp = F :: EXP_BIAS + I :: MAX . ilog2 ( ) + 1 ;
366+ let foobar = F :: EXP_BIAS + I :: UnsignedInt :: BITS - 1 ;
367367
368368 if fbits < F :: ONE . to_bits ( ) {
369369 // < 0 gets rounded to 0
370370 I :: ZERO
371- } else if fbits < F :: Int :: cast_from ( int_max_exp) << F :: SIGNIFICAND_BITS {
371+ } else if fbits < F :: Int :: cast_from ( int_max_exp) << F :: SIG_BITS {
372372 // >= 1, < integer max
373373 let m_base = if I :: UnsignedInt :: BITS >= F :: Int :: BITS {
374- I :: UnsignedInt :: cast_from ( fbits) << ( I :: BITS - F :: SIGNIFICAND_BITS - 1 )
374+ I :: UnsignedInt :: cast_from ( fbits) << ( I :: BITS - F :: SIG_BITS - 1 )
375375 } else {
376- I :: UnsignedInt :: cast_from ( fbits >> ( F :: SIGNIFICAND_BITS - I :: BITS + 1 ) )
376+ I :: UnsignedInt :: cast_from ( fbits >> ( F :: SIG_BITS - I :: BITS + 1 ) )
377377 } ;
378378
379379 // Set the implicit 1-bit.
380- let m: I :: UnsignedInt = I :: UnsignedInt :: ONE << ( I :: BITS - 1 ) | m_base;
380+ let m: I :: UnsignedInt = ( I :: UnsignedInt :: ONE << ( I :: BITS - 1 ) ) | m_base;
381381
382382 // Shift based on the exponent and bias.
383- let s: u32 = ( foobar) - u32:: cast_from ( fbits >> F :: SIGNIFICAND_BITS ) ;
383+ let s: u32 = ( foobar) - u32:: cast_from ( fbits >> F :: SIG_BITS ) ;
384384
385385 let unsigned = m >> s;
386386 map_inbounds ( I :: from_unsigned ( unsigned) )
387- } else if fbits <= F :: EXPONENT_MASK {
387+ } else if fbits <= F :: EXP_MASK {
388388 // >= max (incl. inf)
389389 out_of_bounds ( )
390390 } else {
0 commit comments