Skip to content

Commit 4972e00

Browse files
committed
In ToIntlMathematicalValue(), get MV of numbers via their string value
1 parent 81a18c4 commit 4972e00

File tree

1 file changed

+23
-31
lines changed

1 file changed

+23
-31
lines changed

β€Žspec.emu

Lines changed: 23 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -480,42 +480,34 @@ contributors: Eemeli Aro
480480
1. Let _primValue_ be ? ToPrimitive(_value_, ~number~).
481481
1. If _primValue_ is a BigInt, return <del>ℝ(_primValue_)</del><ins>the Record { [[Value]]: ℝ(_primValue_), [[StringDigits]]: 0 }</ins>.
482482
1. If _primValue_ is a String, then
483-
1. <del>Let _str_ be _primValue_.</del>
484-
1. <ins>Let _text_ be StringToCodePoints(_primValue_).</ins>
485-
1. <ins>Let _literal_ be ParseText(_text_, |StringNumericLiteral|).</ins>
486-
1. <ins>If _literal_ is a List of errors, return the Record { [[Value]]: ~not-a-number~, [[StringDigits]]: 0 }.</ins>
487-
1. <ins>Let _parseRes_ be the StringIntlMV of _literal_.</ins>
488-
1. <ins>Let _x_ be the first element of _parseRes_.</ins>
489-
1. <ins>Let _stringDigits_ be the second element of _parseRes_.</ins>
490-
1. <ins>If _x_ is a mathematical value, then</ins>
491-
1. <ins>Let _rounded_ be RoundMVResult(abs(_x_)).</ins>
492-
1. <ins>If _rounded_ is *+∞*<sub>𝔽</sub>, then</ins>
493-
1. <ins>If _x_ &lt; 0, set _x_ to ~negative-infinity~.</ins>
494-
1. <ins>Else, set _x_ to ~positive-infinity~.</ins>
495-
1. <ins>Set _stringDigits_ to 0.</ins>
496-
1. <ins>If _rounded_ is *+0*<sub>𝔽</sub> and _x_ &lt; 0, set _x_ to ~negative-zero~.</ins>
497-
1. <ins>Return the Record { [[Value]]: _x_, [[StringDigits]]: _stringDigits_ }.</ins>
483+
1. Let _str_ be _primValue_.
498484
1. Else,
499-
1. <del>Let _x_ be ? ToNumber(_primValue_).</del>
500-
1. <del>If _x_ is *-0*<sub>𝔽</sub>, return ~negative-zero~.</del>
501-
1. <del>Let _str_ be Number::toString(_x_, 10).</del>
502-
1. <ins>Let _n_ be ? ToNumber(_primValue_).</ins>
503-
1. <ins>If _n_ is *NaN*, let _x_ be ~not-a-number~.</ins>
504-
1. <ins>Else if _n_ is *+∞*<sub>𝔽</sub>, let _x_ be ~positive-infinity~.</ins>
505-
1. <ins>Else if _n_ is *-∞*<sub>𝔽</sub>, let _x_ be ~negative-infinity~.</ins>
506-
1. <ins>Else, let _x_ be ℝ(_n_).</ins>
507-
1. <ins>Return the Record { [[Value]]: _x_, [[StringDigits]]: 0 }.</ins>
508-
1. <del>Let _text_ be StringToCodePoints(_str_).</del>
509-
1. <del>Let _literal_ be ParseText(_text_, |StringNumericLiteral|).</del>
510-
1. <del>If _literal_ is a List of errors, return ~not-a-number~.</del>
511-
1. <del>Let _intlMV_ be the StringIntlMV of _literal_.</del>
512-
1. <del>If _intlMV_ is a mathematical value, then</del>
513-
1. <del>Let _rounded_ be RoundMVResult(abs(_intlMV_)).</del>
485+
1. Let _x_ be ? ToNumber(_primValue_).
486+
1. If _x_ is *-0*<sub>𝔽</sub>, return <del>~negative-zero~</del><ins>the Record { [[Value]]: ~negative-zero~, [[StringDigits]]: 0 }</ins>.
487+
1. Let _str_ be Number::toString(_x_, 10).
488+
1. Let _text_ be StringToCodePoints(_str_).
489+
1. Let _literal_ be ParseText(_text_, |StringNumericLiteral|).
490+
1. If _literal_ is a List of errors, return <del>~not-a-number~</del><ins>the Record { [[Value]]: ~not-a-number~, [[StringDigits]]: 0 }</ins>.
491+
1. Let <del>_intlMV_</del><ins>_parseRes_</ins> be the StringIntlMV of _literal_.
492+
1. <ins>Let _intlMV_ be the first element of _parseRes_.</ins>
493+
1. <ins>If _primValue_ is a String, then</ins>
494+
1. <ins>Let _stringDigits_ be the second element of _parseRes_.</ins>
495+
1. <ins>Else,</ins>
496+
1. <ins>Let _stringDigits_ be 0.</ins>
497+
1. If _intlMV_ is a mathematical value, then
498+
1. Let _rounded_ be RoundMVResult(abs(_intlMV_)).
514499
1. <del>If _rounded_ is *+∞*<sub>𝔽</sub> and _intlMV_ &lt; 0, return ~negative-infinity~.</del>
515500
1. <del>If _rounded_ is *+∞*<sub>𝔽</sub>, return ~positive-infinity~.</del>
501+
1. <ins>If _rounded_ is *+∞*<sub>𝔽</sub>, then</ins>
502+
1. <ins>If _intlMV_ &lt; 0, set _intlMV_ to ~negative-infinity~.</ins>
503+
1. <ins>Else, set _intlMV_ to ~positive-infinity~.</ins>
504+
1. <ins>Set _stringDigits_ to 0.</ins>
516505
1. <del>If _rounded_ is *+0*<sub>𝔽</sub> and _intlMV_ &lt; 0, return ~negative-zero~.</del>
517506
1. <del>If _rounded_ is *+0*<sub>𝔽</sub>, return 0.</del>
518-
1. <del>Return _intlMV_.</del>
507+
1. <ins>If _rounded_ is *+0*<sub>𝔽</sub>, then</ins>
508+
1. <ins>If _intlMV_ &lt; 0, set _intlMV_ to ~negative-zero~.</ins>
509+
1. <ins>Else, set _intlMV_ to 0.</ins>
510+
1. Return <del>_intlMV_</del><ins>the Record { [[Value]]: _intlMV_, [[StringDigits]]: _stringDigits_ }</ins>.
519511
</emu-alg>
520512
</emu-clause>
521513

0 commit comments

Comments
Β (0)