@@ -106,17 +106,17 @@ mod fpu_precision {
106
106
/// a bignum.
107
107
pub fn fast_path < T : RawFloat > ( integral : & [ u8 ] , fractional : & [ u8 ] , e : i64 ) -> Option < T > {
108
108
let num_digits = integral. len ( ) + fractional. len ( ) ;
109
- // log_10(f64::max_sig ) ~ 15.95. We compare the exact value to max_sig near the end,
109
+ // log_10(f64::MAX_SIG ) ~ 15.95. We compare the exact value to MAX_SIG near the end,
110
110
// this is just a quick, cheap rejection (and also frees the rest of the code from
111
111
// worrying about underflow).
112
112
if num_digits > 16 {
113
113
return None ;
114
114
}
115
- if e. abs ( ) >= T :: ceil_log5_of_max_sig ( ) as i64 {
115
+ if e. abs ( ) >= T :: CEIL_LOG5_OF_MAX_SIG as i64 {
116
116
return None ;
117
117
}
118
118
let f = num:: from_str_unchecked ( integral. iter ( ) . chain ( fractional. iter ( ) ) ) ;
119
- if f > T :: max_sig ( ) {
119
+ if f > T :: MAX_SIG {
120
120
return None ;
121
121
}
122
122
@@ -154,14 +154,14 @@ pub fn fast_path<T: RawFloat>(integral: &[u8], fractional: &[u8], e: i64) -> Opt
154
154
/// > the best possible approximation that uses p bits of significand.)
155
155
pub fn bellerophon < T : RawFloat > ( f : & Big , e : i16 ) -> T {
156
156
let slop;
157
- if f <= & Big :: from_u64 ( T :: max_sig ( ) ) {
157
+ if f <= & Big :: from_u64 ( T :: MAX_SIG ) {
158
158
// The cases abs(e) < log5(2^N) are in fast_path()
159
159
slop = if e >= 0 { 0 } else { 3 } ;
160
160
} else {
161
161
slop = if e >= 0 { 1 } else { 4 } ;
162
162
}
163
163
let z = rawfp:: big_to_fp ( f) . mul ( & power_of_ten ( e) ) . normalize ( ) ;
164
- let exp_p_n = 1 << ( P - T :: sig_bits ( ) as u32 ) ;
164
+ let exp_p_n = 1 << ( P - T :: SIG_BITS as u32 ) ;
165
165
let lowbits: i64 = ( z. f % exp_p_n) as i64 ;
166
166
// Is the slop large enough to make a difference when
167
167
// rounding to n bits?
@@ -210,14 +210,14 @@ fn algorithm_r<T: RawFloat>(f: &Big, e: i16, z0: T) -> T {
210
210
if d2 < y {
211
211
let mut d2_double = d2;
212
212
d2_double. mul_pow2 ( 1 ) ;
213
- if m == T :: min_sig ( ) && d_negative && d2_double > y {
213
+ if m == T :: MIN_SIG && d_negative && d2_double > y {
214
214
z = prev_float ( z) ;
215
215
} else {
216
216
return z;
217
217
}
218
218
} else if d2 == y {
219
219
if m % 2 == 0 {
220
- if m == T :: min_sig ( ) && d_negative {
220
+ if m == T :: MIN_SIG && d_negative {
221
221
z = prev_float ( z) ;
222
222
} else {
223
223
return z;
@@ -303,12 +303,12 @@ pub fn algorithm_m<T: RawFloat>(f: &Big, e: i16) -> T {
303
303
quick_start :: < T > ( & mut u, & mut v, & mut k) ;
304
304
let mut rem = Big :: from_small ( 0 ) ;
305
305
let mut x = Big :: from_small ( 0 ) ;
306
- let min_sig = Big :: from_u64 ( T :: min_sig ( ) ) ;
307
- let max_sig = Big :: from_u64 ( T :: max_sig ( ) ) ;
306
+ let min_sig = Big :: from_u64 ( T :: MIN_SIG ) ;
307
+ let max_sig = Big :: from_u64 ( T :: MAX_SIG ) ;
308
308
loop {
309
309
u. div_rem ( & v, & mut x, & mut rem) ;
310
- if k == T :: min_exp_int ( ) {
311
- // We have to stop at the minimum exponent, if we wait until `k < T::min_exp_int() `,
310
+ if k == T :: MIN_EXP_INT {
311
+ // We have to stop at the minimum exponent, if we wait until `k < T::MIN_EXP_INT `,
312
312
// then we'd be off by a factor of two. Unfortunately this means we have to special-
313
313
// case normal numbers with the minimum exponent.
314
314
// FIXME find a more elegant formulation, but run the `tiny-pow10` test to make sure
@@ -318,8 +318,8 @@ pub fn algorithm_m<T: RawFloat>(f: &Big, e: i16) -> T {
318
318
}
319
319
return underflow ( x, v, rem) ;
320
320
}
321
- if k > T :: max_exp_int ( ) {
322
- return T :: infinity2 ( ) ;
321
+ if k > T :: MAX_EXP_INT {
322
+ return T :: INFINITY ;
323
323
}
324
324
if x < min_sig {
325
325
u. mul_pow2 ( 1 ) ;
@@ -345,18 +345,18 @@ fn quick_start<T: RawFloat>(u: &mut Big, v: &mut Big, k: &mut i16) {
345
345
// The target ratio is one where u/v is in an in-range significand. Thus our termination
346
346
// condition is log2(u / v) being the significand bits, plus/minus one.
347
347
// FIXME Looking at the second bit could improve the estimate and avoid some more divisions.
348
- let target_ratio = T :: sig_bits ( ) as i16 ;
348
+ let target_ratio = T :: SIG_BITS as i16 ;
349
349
let log2_u = u. bit_length ( ) as i16 ;
350
350
let log2_v = v. bit_length ( ) as i16 ;
351
351
let mut u_shift: i16 = 0 ;
352
352
let mut v_shift: i16 = 0 ;
353
353
assert ! ( * k == 0 ) ;
354
354
loop {
355
- if * k == T :: min_exp_int ( ) {
355
+ if * k == T :: MIN_EXP_INT {
356
356
// Underflow or subnormal. Leave it to the main function.
357
357
break ;
358
358
}
359
- if * k == T :: max_exp_int ( ) {
359
+ if * k == T :: MAX_EXP_INT {
360
360
// Overflow. Leave it to the main function.
361
361
break ;
362
362
}
@@ -376,7 +376,7 @@ fn quick_start<T: RawFloat>(u: &mut Big, v: &mut Big, k: &mut i16) {
376
376
}
377
377
378
378
fn underflow < T : RawFloat > ( x : Big , v : Big , rem : Big ) -> T {
379
- if x < Big :: from_u64 ( T :: min_sig ( ) ) {
379
+ if x < Big :: from_u64 ( T :: MIN_SIG ) {
380
380
let q = num:: to_u64 ( & x) ;
381
381
let z = rawfp:: encode_subnormal ( q) ;
382
382
return round_by_remainder ( v, rem, q, z) ;
@@ -395,9 +395,9 @@ fn underflow<T: RawFloat>(x: Big, v: Big, rem: Big) -> T {
395
395
// needs to be rounded up. Only when the rounded off bits are 1/2 and the remainder
396
396
// is zero, we have a half-to-even situation.
397
397
let bits = x. bit_length ( ) ;
398
- let lsb = bits - T :: sig_bits ( ) as usize ;
398
+ let lsb = bits - T :: SIG_BITS as usize ;
399
399
let q = num:: get_bits ( & x, lsb, bits) ;
400
- let k = T :: min_exp_int ( ) + lsb as i16 ;
400
+ let k = T :: MIN_EXP_INT + lsb as i16 ;
401
401
let z = rawfp:: encode_normal ( Unpacked :: new ( q, k) ) ;
402
402
let q_even = q % 2 == 0 ;
403
403
match num:: compare_with_half_ulp ( & x, lsb) {
0 commit comments