Skip to content

Duration Debug for 2.5s rounds inconsistently for duration and duration.as_secs_f64() #103747

Open
@tczajka

Description

@tczajka
use std::time::Duration;

fn main() {
    let a = Duration::new(2, 500000000);
    println!("{:.0?}", a);
    println!("{:.0?}s", a.as_secs_f64());
    println!("{:.0?}", Duration::MAX);
}

I expected this to print (round to even):

2s
2s
18446744073709551616s

Instead, this prints:

3s
2s
0s

Metadata

Metadata

Assignees

No one assigned

    Labels

    A-timeArea: TimeC-bugCategory: This is a bug.T-libsRelevant to the library team, which will review and decide on the PR/issue.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions