Closed
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.)
Metadata
Metadata
Assignees
Labels
Area: Code generation parts specific to LLVM. Both correctness bugs and optimization-related issues.Area: Documentation for any part of the project, including the compiler, standard library, and toolsArea: Floating point numbers and arithmeticRelevant to the library API team, which will review and decide on the PR/issue.