Skip to content

Parse percentage with decimals #698

@Ristaaf

Description

@Ristaaf

Globalize 1.2.2
The example speaks for itself:

Globalize.numberParser({style:"percent"})("50.555%"); => NaN

Globalize.numberParser({style:"percent", maximumFractionDigits: 2})("50.555%") => 0.50555 (actually 0.5055499999999999, but that is another problem)

In fact, I can put any number on the property maximumFractionDigits (which according to the documentation does not even exist on numberParser) and it will parse any number of decimals!

I would expect the first example to behave like the second, or I would like the documentation to be updated, and in that case also the bug which allows any number of decimals to be parsed no matter the value of maximumFractionDigits.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions