Skip to content

Is there a way to multiply out (undo) exponential notation for floats? #779

@petertorelli

Description

@petertorelli

Consider this:

a = 1234.56;
a.toPrecision(3);
// 1.23e+3

How do I force this back to 1230 using .format()? I know I can do it with logs/mods, etc, but I was hoping there's a way to do it with this library. I basically want it to always print significant figures, like toPrecision but without switching to exponents if the significant figures are fewer than or equal to the log10 of the value.

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