Skip to content

Lower/UpperExp inconsistent between integers and floats #89493

Closed
@nrabulinski

Description

@nrabulinski

I tried this code:

println!("{:.*e}", 0, 25);
println!("{:.*e}", 0, 25.0);

I expected to see this happen:
The output should be the same regardless if I'm formatting an integer or a float, in this case most likely 3e1.

Instead, this happened:

3.e1
2e1

Happens in both latest stable and nightly.

EDIT: I'm suspecting this is actually two separate bugs in both the integer and float implementation - the integer result contains a . which should not be there, and the float gets rounded down to 2 despite 25.1 rounding to 3e1 - which is the result I would expect for 25.0 as well.

Metadata

Metadata

Assignees

No one assigned

    Labels

    A-fmtArea: `core::fmt`C-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