Skip to content

Rounding bug between 1001 and 1023 in binary mode #82

@ValentinSteiner

Description

@ValentinSteiner

There seems to be a rounding bug when using the binary option:

Input Actual output Expected output
1001 1000 B 1001 B
1023 1020 B 1023 B
1037263 1010 KiB 1013 KiB
1051013543 1000 MiB 1002 MiB
1054331017 1010 MiB 1005 MiB

Code:
prettyBytes(input, {binary: true})

It appears that the number is rounded to a multiple of ten.
It looks like this only happens for outputs between 1001 and 1023 (inclusive).

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions