From ced972ca4f45eec4db90b7f8f7a5ce00802d5863 Mon Sep 17 00:00:00 2001 From: Jesse Alama Date: Wed, 31 Jul 2024 14:01:28 +0200 Subject: [PATCH] `toFixed`: Permit a rounding mode option --- spec.emu | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/spec.emu b/spec.emu index 2e46e5b5..efd4e943 100644 --- a/spec.emu +++ b/spec.emu @@ -1130,12 +1130,17 @@ location: https://github.com/tc39/proposal-decimal/ 1. Let _O_ be the *this* value. 1. Perform ? RequireInternalSlot(_O_, [[Decimal128Data]]). 1. Let _numDigits_ be *+0*𝔽. + 1. Let _roundingMode_ be *undefined*. 1. If _options_ is not *undefined*, then 1. If _options_ is not an Object, throw a *TypeError* exception. 1. Set _numDigits_ to ? Get(_options_, *"digits"*). 1. If _numDigits_ is not a Number, throw a *TypeError* exception. + 1. Set _roundingMode_ to ? Get(_options_, *"roundingMode"*). 1. If _numDigits_ < 0, throw a *RangeError* exception. 1. If _numDigits_ is not an integer, throw a *RangeError* exception. + 1. If _roundingMode_ is *undefined*, set _roundingMode_ to *"halfEven"*. + 1. Else if _roundingMode_ is not a String, throw a *TypeError* exception. + 1. Else if _roundingMode_ is not a Decimal128 rounding mode, throw a *RangeError* exception. 1. Let _s_ be Decimal128ToDecimalString(_O_, *false*). 1. If _s_ is *"NaN"*, *"Infinity"*, or *"-Infinity"*, return _s_. 1. Let _integerDigits_ be *""*.