Skip to content

numfmt: accepts scientific notation (e.g. 1e9) where GNU rejects as invalid suffix #11655

@sylvestre

Description

@sylvestre

Summary

numfmt accepts numbers in scientific notation (1e9, 5e-3, -71e-9, ...) and converts them, while GNU numfmt rejects the e-suffix entirely as invalid suffix in input.

Found by fuzz_numfmt.

Reproduction

$ /usr/bin/numfmt -- 1e9
numfmt: invalid suffix in input: '1e9'
$ echo $?
2

$ target/debug/numfmt -- 1e9
1000000000
$ echo $?
0

Other examples:

Input uutils stdout GNU
1e-9 1 invalid suffix
5e-3 1 invalid suffix
1e2 100 invalid suffix
-71e-9 -1 invalid suffix

Note also that for sub-unit values like 5e-3 (= 0.005) uutils outputs 1, which does not match a plain truncation or round-to-nearest either.

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