generated from tc39/template-for-proposals
-
Notifications
You must be signed in to change notification settings - Fork 5
Open
Description
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 afractionDigits
orsignificantDigits
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
Labels
No labels