Closed
Description
The issue was noticed because typenum::Pow::powi
returns consistent results between rustc versions while f32::powi
changes.
Given the following code the "std powi" results differ between stable and beta/nightly. Note that code below will run on https://play.rust-lang.org/ but the issue will not reproduce because the host is not Windows. The playground's output for stable/beta/nightly matches stable on my local machine.
extern crate typenum; // 2.12.0
fn main() {
let v = 12.046623229980468750000000000000_f32;
let a = a(v);
let b = b(v);
println!("std powi {:.30?}", a);
println!("typenum {:.30?}", b);
}
#[inline(never)]
fn a(v: f32) -> f32 {
v.powi(3)
}
#[inline(never)]
fn b(v: f32) -> f32 {
typenum::Pow::powi(v, typenum::P3::new())
}
On my Windows 10 machine (and the Travis Win 10 VMs) I get the following results. I'm in the process of bisecting down to a specific nightly right now.
/d/Code/Test/rust/tst (master)$ cargo run; rustc --version --verbose
Finished dev [unoptimized + debuginfo] target(s) in 0.07s
Running `target\debug\tst.exe`
std powi 1748.219482421875000000000000000000
typenum 1748.219482421875000000000000000000
rustc 1.44.0 (49cae5576 2020-06-01)
binary: rustc
commit-hash: 49cae55760da0a43428eba73abcb659bb70cf2e4
commit-date: 2020-06-01
host: x86_64-pc-windows-msvc
release: 1.44.0
LLVM version: 9.0
/d/Code/Test/rust/tst (master)$ cargo +beta run; rustc +beta --version --verbose
Compiling tst v0.1.0 (D:\Code\Test\rust\tst)
Finished dev [unoptimized + debuginfo] target(s) in 4.95s
Running `target\debug\tst.exe`
std powi 1748.219604492187500000000000000000
typenum 1748.219482421875000000000000000000
rustc 1.45.0-beta.3359 (b7dc83a3f 2020-06-03)
binary: rustc
commit-hash: b7dc83a3f6ca9746fb3d121761c3605477b77d90
commit-date: 2020-06-03
host: x86_64-pc-windows-msvc
release: 1.45.0-beta.3359
LLVM version: 10.0
1748.2196044921875
1748.219482421875
Metadata
Metadata
Assignees
Labels
Area: Code generation parts specific to LLVM. Both correctness bugs and optimization-related issues.Area: Floating point numbers and arithmeticCategory: This is a bug.Operating system: WindowsLow priorityRelevant to the compiler team, which will review and decide on the PR/issue.Performance or correctness regression from one stable version to another.Marks issues that should be documented in the release notes of the next release.
Activity