-
Couldn't load subscription status.
- Fork 13.9k
Description
Note: This was deemed a docs issue; see here for more details.
The code below tries to print the minimum positive subnormal number in different ways.
fn main() {
println!("{:e}", f64::from_bits(1));
let divided_minimum_normal = 2f64.powi(-1022) * 2f64.powi(-52);
println!("{:e}", divided_minimum_normal);
let direct_pow = 2f64.powi(-1022 - 52);
println!("{:e}", direct_pow);
}In release mode, this output is given:
5e-324
5e-324
5e-324
In debug mode, this output is given:
5e-324
5e-324
0e0
That is 2f64.powi(-1074) gives different results for release and debug mode. The difference seems to come from LLVM's optimizations, as the IR looks like it is using llvm.powi.f64(2.0, -1074).
I think this is fine. The difference is only in the subnormal range, and I don't think there are any documented guarantees anywhere that are being broken, but I'm posting this issue to make sure.
(This is on both stable 1.42.0 and on nightly.)