<!--
Summary provided to audience:
-->
<style>
/* make code examples suck less */
pre code {
margin: 0 !important;
font-size: 1.25em !important;
}
pre {
padding: 0 !important;
text-align: left !important;
}
.align-left {
text-align: left !important;
}
.small-li li {
font-size: 0.85em !important;
}
</style>
<!-- .slide: data-cover -->
# Amount: Stage 1 Update
Ben Allen & Jesse Alama (Igalia, in collaboration with Google)
November 2025
---
## What is an Amount?
* An Amount is a mathematical value tagged (optionally) with a unit and precision.
* Its API is intentionally very small. There's no arithmetic. You can (re)tag an Amount with a different unit, and update the precision.
---
## Since last time
* Amount is a frequent topic of discussion in the biweekly TC39 JS Numerics call (if you like numbers, please join us!).
* In the pre-plenary JS Numerics breakout session on Monday we spent time talking about how Amount is both an Intl thing as well as *not* an Intl thing. It's a kind of numeric thing but doesn't have arithmetic. What's up with that?
---
## Returning to our roots
* One year ago (2024 TC39 Japan plenary), ~~Amount~~ Measure got to stage 1. At the time, Amount definitely supported some unit conversion.
* We pared the proposal down, renamed it, and focused on the handling of digit strings and precision, and largely neglected units.
* We're building on [keep-trailing-zeros](https://github.com/tc39/proposal-intl-keep-trailing-zeros) regarding precision
---
## Returning to our roots
* There's momentum around the [`<amount>` HTML proposal](https://github.com/mozilla/explainers/blob/main/amount.md) (including last week at W3C TPAC), in which unit conversion is a crucial part.
* Instead of handwaving the story about unit conversion, maybe Amount v1 should do already *some* conversion?
---
## Which units?
* We would like to convert an Amount (with unit) to another Amount, given a new unit.
* Which units might make sense? Naturally, we do not want to depend on unstable data.
* An initial focus could be on SI units (`meter`, `gram`, etc.)
* We could conceivably add more units, such as those relevant for CSS (`em`)
* See also [`CSSUnitValue`](https://developer.mozilla.org/en-US/docs/Web/API/CSSUnitValue)
---
## Which units?
* Other standaridized conversions (e.g. meters to feet) could be included, following [CLDR](https://github.com/unicode-org/cldr/blob/main/common/supplemental/units.xml), which follows NIST (USA), which in turn follows the International Bureau of Weights and Measures.
---
## Proposed data model
* Mathematical values (probably subject to [limits](https://docs.google.com/presentation/d/1NsezmIvFSr4qH4EXnh-cqOjikiUx196feKNM797m6fw/)), together with: NaN, ±♾️, -0
* Temporal-style static constructor `.from` that takes Numbers, BigInts, and (decimal digit) Strings
* `.toString`/`.toLocaleString` for rendering
* `.with` to functionally update an Amount with a new unit/precision
* `.convertTo(unit: string)`: convert an Amount to another Amount with the new unit
* We'd implement the [Intl unit protocol](https://github.com/sffc/proposal-intl-unit-protocol)
---
## For the committee
- We believe that this sketch of Amount is in scope for 262; this is not just about presenting numbers in different locales.
- Is this a worthwhile direction we want us to go in?
- Would you be more on board with this vision of Amount than before?
---
## Discussion
{"type":"slide","slideOptions":{"transition":"slide","theme":"igalia","controlsLayout":"edges","slideNumber":"c/t"}}