Skip to content

What limits should Amount mathematical values have? #37

@jessealama

Description

@jessealama

Amounts are intended to be containers for mathematical values, possibly labelled with a unit. As of writing, there are no limits on the range of these values. We expect that, in a very large portion of uses, programmers will probably stay within the range of Number (or, looking ahead, to Decimal, which is based on IEEE 754 Decimal128, in which values take up 128 bits).

Do we want any limits to be imposed? What should they be?

Considerations for limits in the spec:

  • Although BigInt can be thought of as being an unlimited range, implementations may have limits for them (e.g., hundreds of thousands of digits might be support, but millions of digits wouldn't be).
  • Intl.NumberFormat has various limits on the number of digits it can handle.
  • Clarity and consistency across implementations.

Considerations in favor of no limits in the spec:

  • Amount does not support arithmetic; an Amount is a data holder for a mathematical value. The only calculation that needs to be done on their underlying mathematical values is rounding, which is done (at least, as of writing) only in the constructor and the .with methods when a fractionDigits or significantDigits option is passed in that is requires the mathematical value to be approximated.
  • Implementations are permitted to enforce limits as they see fit, analogous to what they do for BigInt.

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