@@ -806,7 +806,7 @@ mod approx {
806
806
807
807
/// Look-up table for `log10(x) * 1000` where row `i` is used for each `x` having `i` as the
808
808
/// most significant bit. The next 4 bits of `x`, if applicable, are used for the second index.
809
- const LOG10_TIMES_1K : [ [ u64 ; LOWER_BITS_BOUND as usize ] ; BITS as usize ] = [
809
+ const LOG10_TIMES_1K : [ [ u16 ; LOWER_BITS_BOUND as usize ] ; BITS as usize ] = [
810
810
[ 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 ] ,
811
811
[ 301 , 301 , 301 , 301 , 301 , 301 , 301 , 301 , 477 , 477 , 477 , 477 , 477 , 477 , 477 , 477 ] ,
812
812
[ 602 , 602 , 602 , 602 , 699 , 699 , 699 , 699 , 778 , 778 , 778 , 778 , 845 , 845 , 845 , 845 ] ,
@@ -877,11 +877,11 @@ mod approx {
877
877
#[ inline]
878
878
pub fn negative_log10_times_1k ( numerator : u64 , denominator : u64 ) -> u64 {
879
879
// Multiply the -1 through to avoid needing to use signed numbers.
880
- log10_times_1k ( denominator) - log10_times_1k ( numerator)
880
+ ( log10_times_1k ( denominator) - log10_times_1k ( numerator) ) as u64
881
881
}
882
882
883
883
#[ inline]
884
- fn log10_times_1k ( x : u64 ) -> u64 {
884
+ fn log10_times_1k ( x : u64 ) -> u16 {
885
885
debug_assert_ne ! ( x, 0 ) ;
886
886
let most_significant_bit = HIGHEST_BIT - x. leading_zeros ( ) ;
887
887
let lower_bits = ( x >> most_significant_bit. saturating_sub ( LOWER_BITS ) ) & LOWER_BITMASK ;
@@ -897,7 +897,7 @@ mod approx {
897
897
for msb in 0 ..BITS {
898
898
for i in 0 ..LOWER_BITS_BOUND {
899
899
let x = ( ( LOWER_BITS_BOUND + i) << ( HIGHEST_BIT - LOWER_BITS ) ) >> ( HIGHEST_BIT - msb) ;
900
- let log10_times_1k = ( ( x as f64 ) . log10 ( ) * 1000.0 ) . round ( ) as u64 ;
900
+ let log10_times_1k = ( ( x as f64 ) . log10 ( ) * 1000.0 ) . round ( ) as u16 ;
901
901
assert_eq ! ( log10_times_1k, LOG10_TIMES_1K [ msb as usize ] [ i as usize ] ) ;
902
902
903
903
if i % LOWER_BITS_BOUND == 0 {
0 commit comments