From e76e9cfe48b97879c53ff5de065faec46203a55a Mon Sep 17 00:00:00 2001 From: Jesse Alama Date: Wed, 11 Dec 2024 15:17:09 +0100 Subject: [PATCH] Fix rendering of values in exponential format --- spec.emu | 15 +++++---------- 1 file changed, 5 insertions(+), 10 deletions(-) diff --git a/spec.emu b/spec.emu index 32dae69..620633f 100644 --- a/spec.emu +++ b/spec.emu @@ -301,16 +301,11 @@ location: https://github.com/tc39/proposal-decimal/ 1. Let _argument_ be Decimal128Abs(_argument_). 1. If _sign_ = -1, let _prefix_ be *"-"*, else let _prefix_ be *""*. 1. If _argument_ is *+0*𝔻 or *−0*𝔻, return the string concatenation of _prefix_ and *"0e+0". - 1. Let _q_ be the largest integer such that _argument_ × 10−_q_ is an integer. - 1. Let _n_ be _argument_ × 10−_q_. - 1. Assert: 0 < _n_ < 1034. - 1. Let _coefficientStr_ be the unique decimal string representation of _n_ without leading zeroes. - 1. Let _e_ be the unique integer for which 1 ≤ _n_ × 10_e_ < 10. - 1. Let _adjustedExp_ be -_e_. - 1. Let _adjustedExpStr_ be the unique decimal string representation of _adjustedExp_ without leading zeroes. - 1. Let _firstDigit_ be the substring of _coefficientStr_ from 0 to 1. - 1. Let _remainingDigits_ be the substring of _coefficientStr_ starting at 1. - 1. Return the concatenation of _prefix_, _firstDigit_, *"."*, _remainingDigits_, *"e"*, and _adjustedExpStr_. + 1. Let _e_ be the unique integer for which 1 ≤ _argument_ × 10_e_ < 10. + 1. Let _mantissa_ be _argument_ / 10_e_. + 1. Let _coefficientStr_ be Decimal128ToDecimalString(_mantissa_). + 1. Let _exponentStr_ be the unique decimal string representation of _e_ without leading zeroes. + 1. Return the concatenation of _prefix_, _coefficientStr_, *"e"*, and _exponentStr_.