Skip to content

Exponent detection with precision not working properly #200

@elfkuzco

Description

@elfkuzco

While using the library to format filesizes, it tends to show numbers in a weird way with fixed precision (most likely) because it is not computing the proper exponent.
Example:

Without precison

> filesize.filesize(1058223158, {base: 2, standard: 'iec'})
'1009.2 MiB'
> filesize.filesize(529825922, {base: 2, standard: 'iec'})
'505.28 MiB'

With precison

> filesize.filesize(1058223158, {base: 2, standard: 'iec', precision: 3})
'1.01e+3 MiB'
> filesize.filesize(529825922, {base: 2, standard: 'iec', precision: 3})
'505 MiB'

While not using precision seems to give a more readable output, I would like to use a defined precision and have '1.01e+3 MiB' shown as '0.990 GiB' instead.

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