Skip to content

Improve readability of SI format for very small/large numbers #111

@patkwee

Description

@patkwee

It would be great to improve the 'human-readability' of SI format "s" for very small/large numbers. At the moment d3-format generates:

console.log(format("s")(1e-50))  -> "0.00000000000000000000000001y"
console.log(format("s")(1e+50)) -> "100000000000000000000000000Y"

I would propose to fall back to exponent notation ("e" format) for numbers below abs(x)<1e-24 or above abs(x)>1e24.

In my application, usually the numbers are in a range where the "s"-format makes sense. Though, sometimes, e.g. due to numerical inaccuracy of calculations, I get very small numbers, that blow-up my output.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions