Closed
Description
Related release note: https://github.com/rust-lang/rust/blob/stable/RELEASES.md#libraries-3Related PR: Improve Duration::try_from_secs_f32/64 accuracy by directly processing exponent and mantissa #90247
Though the PR describes the change is related to improve its truncation better, the changed behavior is rounding up which was down before.
EDIT: The upper changes and issue related to 1.60. It is not related to this issue.
I want to check if this is expected change or regression.
Code
I tried this code:
use std::time::Duration;
fn main() {
let f: f64 = 1.0020030005;
let d = Duration::from_secs_f64(f);
println!("{d:?}");
}
I expected to see this happen: explanation
Until 1.62.1,
1.002003s
Instead, this happened: explanation
In 1.63.0,
1.002003001s
Version it worked on
It most recently worked on: Until 1.62.1
Version with regression
rustc --version --verbose
:
rustc 1.63.0 (4b91a6ea7 2022-08-08)
binary: rustc
commit-hash: 4b91a6ea7258a947e59c6522cd5898e7c0a6a88f
commit-date: 2022-08-08
host: aarch64-apple-darwin
release: 1.63.0
LLVM version: 14.0.5