Skip to content

numfmt: large integers lose precision (f64 rounding) vs GNU #11654

@sylvestre

Description

@sylvestre

Summary

numfmt rounds large integers to the nearest representable f64, while GNU numfmt preserves the exact value when no scaling is needed.

Found by fuzz_numfmt.

Reproduction

$ /usr/bin/numfmt --from=iec 9153396227555392131
9153396227555392131

$ target/debug/numfmt --from=iec 9153396227555392131
9153396227555392512

9153396227555392131 is greater than 2^53, so it can't be represented exactly as f64; uutils appears to parse the input through f64 and loses the last few digits.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions