We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
1 parent 294ce40 commit f5df406Copy full SHA for f5df406
src/hazmat/primecount.rs
@@ -23,6 +23,9 @@ fn ln<const LIMBS: usize>(x: &Uint<LIMBS>) -> u64 {
23
let log2_x = U256::from(x.bits_vartime().saturating_sub(1));
24
// The error in this approximation is "lower 128 bits of the product"/2^128, which is on the order of 10^-40.
25
let ln_x: U256 = (log2_x * SCALED_LN2) >> 128;
26
+ #[cfg(target_pointer_width = "32")]
27
+ let ln_x = (ln_x.as_limbs()[1].0 as u64) << 32 | ln_x.as_limbs()[0].0 as u64;
28
+ #[cfg(target_pointer_width = "64")]
29
let ln_x = ln_x.as_limbs()[0].0;
30
ln_x & !((ln_x == 0) as u64) // Ensure we return 0 for ln(1)
31
}
0 commit comments