Skip to content

Fix Duration::from_secs_f32 #90231

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 1 commit into from
Closed

Fix Duration::from_secs_f32 #90231

wants to merge 1 commit into from

Conversation

manio
Copy link

@manio manio commented Oct 24, 2021

Currently the function is returning wrong values, eg:
Duration::from_secs_f32(30.0);
is giving:
30.000001024s (30s + 1024ns)
This commit fixes this problem.

Fixes: #90225

Currently the function is returning wrong values, eg:
Duration::from_secs_f32(30.0);
is giving:
30.000001024s (30s + 1024ns)
This commit fixes this problem.

Fixes: rust-lang#90225
@rust-highfive
Copy link
Contributor

Thanks for the pull request, and welcome! The Rust team is excited to review your changes, and you should hear from @kennytm (or someone else) soon.

Please see the contribution instructions for more information.

@rust-highfive rust-highfive added the S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. label Oct 24, 2021
@rust-log-analyzer
Copy link
Collaborator

The job x86_64-gnu-llvm-12 failed! Check out the build log: (web) (plain)

Click to see the possible cause of the failure (guessed by this bot)
   Compiling unwind v0.0.0 (/checkout/library/unwind)
error[E0308]: mismatched types
   --> library/core/src/time.rs:818:28
    |
818 |         } else if nanos >= MAX_NANOS_F32 {
    |                            ^^^^^^^^^^^^^ expected `f64`, found `f32`
For more information about this error, try `rustc --explain E0308`.
error: could not compile `core` due to previous error
Build completed unsuccessfully in 0:00:08

@manio
Copy link
Author

manio commented Oct 24, 2021

Hmmm... probably bad approach. Closing...

@manio manio closed this Oct 24, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
S-waiting-on-review Status: Awaiting review from the assignee but also interested parties.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Duration::from_secs_f32 gives wrong results
4 participants