File tree 1 file changed +2
-3
lines changed
1 file changed +2
-3
lines changed Original file line number Diff line number Diff line change @@ -10,8 +10,7 @@ pub fn estimate_pi_x<const LIMBS: usize>(x: &Uint<LIMBS>) -> Uint<LIMBS> {
10
10
let ln_x = ln_x as f64 ;
11
11
let ln_x_sq = ln_x * ln_x;
12
12
let term2 = ( 1.0 + 1.0 / ln_x + 2.0 / ( ln_x_sq) + 6.0 / ( ln_x_sq * ln_x) ) as u64 ;
13
- let pi_x = term1 * Uint :: < LIMBS > :: from_u64 ( term2) ;
14
- pi_x
13
+ term1 * Uint :: < LIMBS > :: from_u64 ( term2)
15
14
}
16
15
17
16
// Calculate the natural logarithm of a big integer using the relation ln(x) = log₂(x) / log₂(e).
@@ -40,7 +39,7 @@ mod tests {
40
39
for exponent in 1 ..=35 {
41
40
let x = U256 :: from_u128 ( 10u128 . pow ( exponent) ) ;
42
41
let ln_x = ln ( & x) ;
43
- let expected_ln_x = ( exponent as f64 * 2.302585092994046 ) as u64 ; // ln(10^exponent) = exponent * ln(10)
42
+ let expected_ln_x = ( exponent as f64 * core :: f64 :: consts :: LN_10 ) as u64 ; // ln(10^exponent) = exponent * ln(10)
44
43
let delta = ln_x. abs_diff ( expected_ln_x) ;
45
44
assert ! (
46
45
delta < 2 ,
You can’t perform that action at this time.
0 commit comments