Skip to content

Commit e76e9cf

Browse files
committed
Fix rendering of values in exponential format
1 parent e491fac commit e76e9cf

File tree

1 file changed

+5
-10
lines changed

1 file changed

+5
-10
lines changed

spec.emu

+5-10
Original file line numberDiff line numberDiff line change
@@ -301,16 +301,11 @@ location: https://github.com/tc39/proposal-decimal/
301301
1. Let _argument_ be Decimal128Abs(_argument_).
302302
1. If _sign_ = -1, let _prefix_ be *"-"*, else let _prefix_ be *""*.
303303
1. If _argument_ is *+0*<sub>𝔻</sub> or *−0*<sub>𝔻</sub>, return the string concatenation of _prefix_ and *"0e+0".
304-
1. Let _q_ be the largest integer such that _argument_ × 10<sup>−_q_</sup> is an integer.
305-
1. Let _n_ be _argument_ × 10<sup>−_q_</sup>.
306-
1. Assert: 0 < _n_ < 10<sup>34</sup>.
307-
1. Let _coefficientStr_ be the unique decimal string representation of _n_ without leading zeroes.
308-
1. Let _e_ be the unique integer for which 1 ≤ _n_ × 10<sup>_e_</sup> < 10.
309-
1. Let _adjustedExp_ be -_e_.
310-
1. Let _adjustedExpStr_ be the unique decimal string representation of _adjustedExp_ without leading zeroes.
311-
1. Let _firstDigit_ be the substring of _coefficientStr_ from 0 to 1.
312-
1. Let _remainingDigits_ be the substring of _coefficientStr_ starting at 1.
313-
1. Return the concatenation of _prefix_, _firstDigit_, *"."*, _remainingDigits_, *"e"*, and _adjustedExpStr_.
304+
1. Let _e_ be the unique integer for which 1 ≤ _argument_ × 10<sup>_e_</sup> < 10.
305+
1. Let _mantissa_ be _argument_ / 10<sup>_e_</sup>.
306+
1. Let _coefficientStr_ be Decimal128ToDecimalString(_mantissa_).
307+
1. Let _exponentStr_ be the unique decimal string representation of _e_ without leading zeroes.
308+
1. Return the concatenation of _prefix_, _coefficientStr_, *"e"*, and _exponentStr_.
314309
</emu-alg>
315310
</emu-clause>
316311

0 commit comments

Comments
 (0)