diff --git a/spec/numberformat.html b/spec/numberformat.html index 493b263c..262da474 100644 --- a/spec/numberformat.html +++ b/spec/numberformat.html @@ -104,21 +104,17 @@

Number Format Functions

- -

FormatNumber(numberFormat, x)

+ +

PartitionNumberPattern(numberFormat, x)

- When the FormatNumber abstract operation is called with arguments _numberFormat_ (which must be an object initialized as a NumberFormat) and _x_ (which must be a Number value), it returns a String value representing _x_ according to the effective locale and the formatting options of _numberFormat_. This abstract operation functions as follows: + The *PartitionNumberPattern* abstract operation is called with arguments _numberFormat_ (which must be an object initialized as a NumberFormat) and _x_ (which must be a Number value), interprets _x_ as a numeric value, and creates the corresponding parts according to the effective locale and the formatting options of _numberFormat_. The following steps are taken:

- 1. Let _negative_ be *false*. - 1. If the _result_ of isFinite(_x_) is *false*, then - 1. If _x_ is *NaN*, - 1. Let _n_ be an ILD String value indicating the *NaN* value. - 1. Else, - 1. Let _n_ be an ILD String value indicating infinity. - 1. If _x_ < 0, let _negative_ be *true*. + 1. If _x_ is not *NaN* and _x_ < 0, then: + 1. Let _x_ be -_x_. + 1. Let _pattern_ be _numberFormat_.[[negativePattern]]. 1. Else, 1. If _x_ < 0, then 1. Let _negative_ be *true*. @@ -151,7 +147,6 @@

FormatNumber(numberFormat, x)

1. Return _result_.
- Numbering systems with simple digit mappings @@ -257,10 +252,47 @@

FormatNumber(numberFormat, x)

- It is recommended that implementations use the locale data provided by the Common Locale Data Repository (available at http://cldr.unicode.org/). + It is recommended that implementations use the locale provided by the Common Locale Data Repository (available at http://cldr.unicode.org/). + +

FormatNumber(numberFormat, x)

+ +

+ The FormatNumber abstract operation is called with arguments _numberFormat_ (which must be an object initialized as a NumberFormat) and _x_ (which must be a Number value), and performs the following steps: +

+ + + 1. Let _parts_ be ? PartitionNumberPattern(_numberFormat_, _x_). + 1. Let _result_ be an empty String. + 1. For each _part_ in _parts_, do: + 1. Set _result_ to a String value produced by concatenating _result_ and _part_.[[value]]. + 1. Return _result_. + +
+ + +

FormatNumberToParts(numberFormat, x)

+ +

+ The FormatNumberToParts abstract operation is called with arguments _numberFormat_ (which must be an object initialized as a NumberFormat) and _x_ (which must be a Number value), and performs the following steps: +

+ + + 1. Let _parts_ be ? PartitionNumberPattern(_numberFormat_, _x_). + 1. Let _result_ be ArrayCreate(0). + 1. Let _n_ be 0. + 1. For each _part_ in _parts_, do: + 1. Let _O_ be ObjectCreate(%ObjectPrototype%). + 1. Perform ? CreateDataPropertyOrThrow(_O_, "type", _part_.[[type]]). + 1. Perform ? CreateDataPropertyOrThrow(_O_, "value", _part_.[[value]]). + 1. Perform ? CreateDataPropertyOrThrow(_result_, ? ToString(_n_), _O_). + 1. Increment _n_ by 1. + 1. Return _result_. + +
+

ToRawPrecision(x, minPrecision, maxPrecision)

@@ -409,7 +441,7 @@

Internal slots

  • The array that is the value of the "nu" property of any locale property of [[localeData]] must not include the values "native", "traditio", or "finance".
  • -
  • [[localeData]][locale] must have a patterns property for all locale values. The value of this property must be an object, which must have properties with the names of the three number format styles: *"decimal"*, *"percent"*, and *"currency"*. Each of these properties in turn must be an object with the properties positivePattern and negativePattern. The value of these properties must be string values that contain a substring *"{number}"*; the values within the currency property must also contain a substring *"{currency}"*. The pattern strings must not contain any characters in the General Category “Number, decimal digit" as specified by the Unicode Standard.
  • +
  • [[localeData]][locale] must have a patterns property for all locale values. The value of this property must be an object, which must have properties with the names of the three number format styles: *"decimal"*, *"percent"*, and *"currency"*. Each of these properties in turn must be an object with the properties positivePattern and negativePattern. The value of these properties must be string values that must contain the substring *"{number}"* and may contain the substrings *"{plusSign}"*, and *"{minusSign}"*; the values within the percent property must also contain the substring *"{percentSign}"*; the values within the currency property must also contain the substring *"{currency}"*. The pattern strings must not contain any characters in the General Category “Number, decimal digit" as specified by the Unicode Standard.
@@ -457,16 +489,33 @@

get Intl.NumberFormat.prototype.format

1. Let _nf_ be *this* value. 1. If Type(_nf_) is not Object, throw a *TypeError* exception. - 1. If _nf_ does not have an [[initializedNumberFormat]] internal slot, throw a *TypeError* exception. + 1. If _nf_.[[initializedNumberFormat]] is *true*, throw a *TypeError* exception. 1. If _nf_.[[boundFormat]] is *undefined*, then 1. Let _F_ be a new built-in function object as defined in Number Format Functions (). 1. Let _bf_ be BoundFunctionCreate(_F_, _nf_, « »). 1. Perform ! DefinePropertyOrThrow(_bf_, `"length"`, PropertyDescriptor {[[Value]]: 1, [[Writable]]: *false*, [[Enumerable]]: *false*, [[Configurable]]: *true*}). - 1. Set _nf_.[[boundFormat]] to bf. + 1. Set _nf_.[[boundFormat]] to _bf_. 1. Return _nf_.[[boundFormat]].
+ +

Intl.NumberFormat.prototype.formatToParts ([ value ])

+ +

+ When the *Intl.NumberFormat.prototype.formatToParts* is called with an optional argument _value_, the following steps are taken: +

+ + + 1. Let _nf_ be *this* value. + 1. If Type(_nf_) is not Object, throw a *TypeError* exception. + 1. If _nf_ does not have an [[initializedNumberFormat]] internal slot, throw a *TypeError* exception. + 1. If _value_ is not provided, let _value_ be *undefined*. + 1. Let _x_ be ? ToNumber(_value_). + 1. Return ? FormatNumberToParts(_nf_, _x_). + +
+

Intl.NumberFormat.prototype.resolvedOptions ()