这是indexloc提供的服务,不要输入任何密码
Skip to content

Largest and smallest string decimals #27

@sffc

Description

@sffc

According to ECMA-402, the smallest positive string decimal that is able to be formatted is: the string decimal representing the smallest number that is closer to the smallest subnormal float than to zero.

The smallest subnormal float is 5e-324 or 4.94065645841246544177…e-324

This means that 2.47032822920623272089e-324 is the smallest decimal value supported in Intl.NumberFormat when rounded to 21 significant digits. However, the check is technically performed before rounding.

Likewise, the largest positive string decimal is the one representing the number closer to Number.MAX_VALUE than what would be the next tick above it (?).

The precision of the formatted output is bounded by 21 significant digits for small numbers and 100 fraction digits for large numbers. For magnitudes smaller than 1e-79, the max significant digits rule, and for magnitudes larger than 1e-79, the max fraction digits rule. In a String Amount, I would suggest applying these bounds upon construction.

CC @nicolo-ribaudo @eemeli

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions