diff --git a/spec.emu b/spec.emu index a8a9e3a..131ff8c 100644 --- a/spec.emu +++ b/spec.emu @@ -1,4 +1,4 @@ - + @@ -97,9 +97,15 @@ contributors: Eemeli Aro 1. Else, 1. If _x_ is not ~negative-zero~, then 1. Assert: _x_ is a mathematical value. - 1. If _numberFormat_.[[Style]] is *"percent"*, set _x_ be 100 × _x_. + 1. If _x_ = 0, let _magnitude_ be -∞. + 1. Else, let _magnitude_ be the base 10 logarithm of abs(_x_) rounded down to the nearest integer. + 1. If _numberFormat_.[[Style]] is *"percent"*, set _x_ be 100 × _x_., then + 1. Set _x_ to 100 × _x_. + 1. If _magnitude_ < 0, set _stringDigitCount_ to _stringDigitCount_ + max(_magnitude_, -2). + 1. Set _magnitude_ to _magnitude_ + 2. 1. Set _exponent_ to ComputeExponent(_numberFormat_, _x_). 1. Set _x_ to _x_ × 10-_exponent_. + 1. If _magnitude_ < 0 and _exponent_ < 0, set _stringDigitCount_ to _stringDigitCount_ + max(_magnitude_, _exponent_). 1. Let _formatNumberResult_ be FormatNumericToString(_numberFormat_, _x_, _stringDigitCount_). 1. Let _n_ be _formatNumberResult_.[[FormattedString]]. 1. Set _x_ to _formatNumberResult_.[[RoundedNumber]]. @@ -162,7 +168,7 @@ contributors: Eemeli Aro

PartitionNotationSubPattern ( _numberFormat_: an Intl.NumberFormat, - _x_: an Intla mathematical value, or ~negative-zero~. + _x_: an Intla mathematical value or ~negative-zero~, _n_: a String, _exponent_: an integer, ): a List of Records with fields [[Type]] (a String) and [[Value]] (a String) @@ -405,6 +411,7 @@ contributors: Eemeli Aro

+ ZeroDigits ::: `0` ZeroDigits? StringNumericLiteral ::: StrWhiteSpace? 1. Return 0« 0, 0 ». @@ -432,10 +439,16 @@ contributors: Eemeli Aro 1. Return ~positive-infinity~« ~positive-infinity~, 0 ». - StrUnsignedDecimalLiteral ::: DecimalDigits `.` DecimalDigits? ExponentPart? + StrUnsignedDecimalLiteral ::: DecimalDigits ZeroDigits? NonZeroDigit DecimalDigits? `.` DecimalDigits? ExponentPart? - 1. Let _a_ be MV of the first |DecimalDigits|. - 1. Let _m_ be the number of code points in the first |DecimalDigits|. + 1. Let _a_ be MV of the first |DecimalDigits|. + 1. If the first |DecimalDigits| is present, then + 1. Let _m_ be the number of code points in the first |DecimalDigits|. + 1. Let _a_ be the MV of |NonZeroDigit| × 10_m_ plus the MV of the first |DecimalDigits|. + 1. Set _m_ to 1 + _m_. + 1. Else, + 1. Let _m_ be 1. + 1. Let _a_ be the MV of |NonZeroDigit|. 1. If the second |DecimalDigits| is present, then 1. Let _b_ be MV of the second |DecimalDigits|. 1. Let _n_ be the number of code points in the second |DecimalDigits|. @@ -445,20 +458,31 @@ contributors: Eemeli Aro 1. If |ExponentPart| is present, let _e_ be MV of |ExponentPart|. Otherwise, let _e_ be 0. 1. Return « (_a_ + (_b_ × 10-_n_)) × 10_e_, _m_ + _n_ ». - StrUnsignedDecimalLiteral ::: `.` DecimalDigits ExponentPart? + StrUnsignedDecimalLiteral ::: ZeroDigits? `.` DecimalDigits ExponentPart? 1. Let _b_ be MV of |DecimalDigits|. 1. If |ExponentPart| is present, let _e_ be MV of |ExponentPart|. Otherwise, let _e_ be 0. 1. Let _n_ be the number of code points in |DecimalDigits|. - 1. Return « _b_ × 10_e_ - _n_, _n_ ». + 1. Return « _b_ × 10_e_ - _n_, 1 + _n_ ». - StrUnsignedDecimalLiteral ::: DecimalDigits ExponentPart? + StrUnsignedDecimalLiteral ::: DecimalDigits ZeroDigits? NonZeroDigit DecimalDigits? ExponentPart? - 1. Let _a_ be MV of |DecimalDigits|. + 1. Let _a_ be MV of |DecimalDigits|. + 1. If the |DecimalDigits| is present, then + 1. Let _m_ be the number of code points in |DecimalDigits|. + 1. Let _a_ be the MV of |NonZeroDigit| × 10_m_ plus the MV of |DecimalDigits|. + 1. Set _m_ to 1 + _m_. + 1. Else, + 1. Let _m_ be 1. + 1. Let _a_ be the MV of the |NonZeroDigit|. 1. Let _m_ be the number of code points in |DecimalDigits|. 1. If |ExponentPart| is present, let _e_ be MV of |ExponentPart|. Otherwise, let _e_ be 0. 1. Return « _a_ × 10_e_, _m_ ». + StrUnsignedDecimalLiteral ::: ZeroDigits ExponentPart? + + 1. Return « 0, 0 ». +