This definition supersedes the definition provided in es2025,
- This definition supersedes the definition provided in es2025,
This function performs the following steps when called:
-- This function performs the following steps when called: -
+This definition supersedes the definition provided in es2025,
This function performs the following steps when called:
<unitPreferences> element data of UTS #35 Part 6 Supplemental, Unit Preferences includes data.
+ 1. Let _localeData_ be a Record whose field names are the elements of _availableLocales_ and whose values are Records.
+ 1. Let _r_ be ResolveLocale(_availableLocales_, _requestedLocales_, the Record { [[localeMatcher]]: _localeMatcher_ }, « », _localeData_).
+ 1. Let _locale_ be _r_.[[Locale]].
+ 1. Let _preferredUnit_ be the preferred unit for _category_, _locale_, _usage_, and _sourceValue_ as specified by the <unitPreferences> element data of UTS #35 Part 6 Supplemental, Unit Preferences.
+ 1. If _preferredUnit_ is *undefined*, throw a *RangeError* exception.
+ 1. Return _preferredUnit_.
+ The following entry is to be added to ECMA-402's list of referenced parts of Unicode Technical Standard #35.
+This specification consists of two parts:
+ The changes proposed here are stacked on top of the Keep Trailing Zeros ECMA-402 proposal, + and include calls to ECMA-402 Abstract Operations from ECMA-262 algorithms. + Where necessary, we intend to promote those semantics to ECMA-262. +
+An Amount is an object that wraps mathematical value and a precision, together with a unit (e.g., mile, kilogram, EUR, JPY, USD-per-mile). One can intuitively understand an Amount as a number that, so to speak, knows its own precision and what it is measuring.
-The notation for mathematical values used by Amount are decimal digit string, which are Strings that adhere to the
An Amount is an object that wraps a numeric value—as a Number, BigInt, or String—together with an optional unit (e.g., mile, kilogram, EUR, JPY, USD-per-mile). One can intuitively understand an Amount as a value that, so to speak, knows what it is measuring.
+When precision options (such as fractionDigits or significantDigits) are applied, or when unit conversion is performed, the numeric value is stored as a decimal digit string, which is a String in |StrDecimalLiteral| form or *"NaN"*. Otherwise, the original JavaScript value type (Number, BigInt, or String) is retained.
Rounding a mathematical value is an important part of this spec. When we say rounding mode in this specification we simply refer to
The
- conversion of a |StringNumericLiteral| to a Number value is similar overall to the determination of the NumericValue of a |NumericLiteral| (see
- The conversion of a |StringNumericLiteral| to a mathematical value and a precision is similar overall to the determination of the NumericValue of a |NumericLiteral| (see
It computes the power of 10 of the least significant precise digit of a |StringNumericLiteral|.
-+ This abstract operation will need to be overridden in the 402 part because it will read additional Intl-specific properties beyond these. +
+special conversion, throw a *RangeError* exception.
+ 1. Let _category_ be the unit category of _unit_ as specified by the CLDR unit conversion data.
+ 1. Let _factor_ be the Number value closest to the rational conversion factor for _unit_ as specified by the CLDR unit conversion data.
+ 1. If the CLDR unit conversion data specifies a conversion offset for _unit_, let _offset_ be the Number value closest to that rational offset; otherwise, let _offset_ be *+0*𝔽.
+ 1. Return the Record { [[Category]]: _category_, [[Factor]]: _factor_, [[Offset]]: _offset_ }.
The formula for converting a value in _unit_ to its base unit is: baseValue = value × [[Factor]] + [[Offset]].
+CLDR expresses conversion factors as rational numbers (e.g., 0.3048/12 for inch-to-meter). These rational values are converted to Numbers before use, so conversion arithmetic is subject to the precision of IEEE 754 binary64. For example, converting 1.75 feet to inches yields 1.75 × 0.3048 / (0.3048 / 12) = 20.999999999999996, not exactly 21.
+CLDR also defines nonlinear conversions via the special attribute (e.g., the Beaufort scale). These cannot be expressed as a linear factor and offset, so they are excluded from this operation.
Given a Number argument, the constructor converts it to a String using the
When no precision options are given, Number and BigInt arguments are stored directly in [[AmountValue]], preserving the original type. String arguments are normalized to StrDecimalLiteral form. When precision options are specified, [[AmountValue]] always holds a String.
++ We intend to move 402's FormatNumericToString, and its dependent AOs, to 262, possibly renamed. +
This accessor property, whose set accessor function is *undefined*, stores a Number value indicating how many fraction digits an Amount contains. Its get accessor function performs the following steps when called:
+This accessor property, whose set accessor function is *undefined*, returns the numeric value of the Amount. Its get accessor function performs the following steps when called:
This accessor property, whose set accessor function is *undefined*, stores a Number value indicating how many significant digits an Amount contains. Its get accessor function performs the following steps when called:
-The value may be a Number, BigInt, or String. It is a String when precision options were applied during construction or when the Amount is the result of unit conversion.
+This accessor property, whose set accessor function is *undefined*, stores a String value (or *undefined*) indicating the unit that this Amount has. Its get accessor function performs the following steps when called:
+This accessor property, whose set accessor function is *undefined*, returns a String value (or *undefined*) indicating the unit that this Amount has. Its get accessor function performs the following steps when called:
This method returns a String value that renders the underlying mathematical value according to its precision, as well as a unit indicator, if present.
+This method returns a String representation of the Amount, including a unit indicator in bracket notation.
It performs the following steps when called:
An ECMAScript implementation that includes the ECMA-402 Internationalization API must implement this method as specified in the ECMA-402 specification. If an ECMAScript implementation does not include the ECMA-402 API the following specification of this method is used:
-This method produces a String value that represents this Amount object formatted according to the conventions of the host environment’s current locale. This method is implementation-defined, and it is permissible, but not encouraged, for it to return the same thing as
The meanings of the optional parameters to this method are defined in the ECMA-402 specification; implementations that do not include ECMA-402 support must not use those parameter positions for anything else.
-This method returns a fresh Amount object whose underlying mathematical value is equal to the mathematical value of the current Amount, but possibly with different precision as specified in the _options_.
+An ECMAScript implementation that includes the ECMA-402 Internationalization API must implement this method as specified in the ECMA-402 specification. If an ECMAScript implementation does not include the ECMA-402 API the following specification of this method is used:
It performs the following steps when called:
The meanings of the optional parameters to this method are defined in the ECMA-402 specification; implementations that do not include ECMA-402 support must not use those parameter positions for anything else.
This method is called by ECMAScript language operators to convert an Amount to a primitive value. The allowed values are *"default"*, *"number"*, and *"string"*. The default is *"number."*
+This method returns a new Amount whose value is the result of converting this Amount’s value from its current unit to a target unit. The target unit is specified by _options_.
It performs the following steps when called:
An ECMAScript implementation that includes the ECMA-402 Internationalization API supersedes this method to additionally support locale-based and usage-based unit conversion via CLDR unit preferences data. Without ECMA-402, only explicit unit-to-unit conversion (via the *"unit"* option) is supported.
+