+ Number.prototype.toFixed ( _fractionDigits_ )
+
+ This method returns a String containing this Number value represented in decimal fixed-point notation with _fractionDigits_ digits after the decimal point. If _fractionDigits_ is *undefined*, 0 is assumed.
+
+ It performs the following steps when called:
+
+ 1. Let _x_ be ? ThisNumberValue(*this* value).
+ 1. Let _f_ be ? ToIntegerOrInfinity(_fractionDigits_).
+ 1. Assert: If _fractionDigits_ is *undefined*, then _f_ is 0.
+ 1. If _f_ is not finite, throw a *RangeError* exception.
+ 1. If _f_ < 0 or _f_ > 100, throw a *RangeError* exception.
+ 1. If _x_ is not finite, return Number::toString(_x_, 10).
+ 1. Return MVtoDecimalString(ℝ(_x_), _f_).
+ 1. Set _x_ to ℝ(_x_).
+ 1. Let _s_ be the empty String.
+ 1. If _x_ < 0, then
+ 1. Set _s_ to *"-"*.
+ 1. Set _x_ to -_x_.
+ 1. If _x_ ≥ 1021, then
+ 1. Let _m_ be ! ToString(𝔽(_x_)).
+ 1. Else,
+ 1. Let _n_ be an integer for which _n_ / 10_f_ - _x_ is as close to zero as possible. If there are two such _n_, pick the larger _n_.
+ 1. If _n_ = 0, let _m_ be *"0"*. Otherwise, let _m_ be the String value consisting of the digits of the decimal representation of _n_ (in order, with no leading zeroes).
+ 1. If _f_ ≠ 0, then
+ 1. Let _k_ be the length of _m_.
+ 1. If _k_ ≤ _f_, then
+ 1. Let _z_ be the String value consisting of _f_ + 1 - _k_ occurrences of the code unit 0x0030 (DIGIT ZERO).
+ 1. Set _m_ to the string-concatenation of _z_ and _m_.
+ 1. Set _k_ to _f_ + 1.
+ 1. Let _a_ be the first _k_ - _f_ code units of _m_.
+ 1. Let _b_ be the other _f_ code units of _m_.
+ 1. Set _m_ to the string-concatenation of _a_, *"."*, and _b_.
+ 1. Return the string-concatenation of _s_ and _m_.
+
+
+ The output of `toFixed` may be more precise than `toString` for some values because toString only prints enough significant digits to distinguish the number from adjacent Number values. For example,
+
+ `(1000000000000000128).toString()` returns *"1000000000000000100"*, while
+ `(1000000000000000128).toFixed(0)` returns *"1000000000000000128"*.
+
+
+
+
+ MVtoDecimalString (
+ _x_: a mathematical value,
+ _fractionDigits_ : a non-negative integer
+ ): a String
+
+
+
+ 1. Let _s_ be the empty String.
+ 1. If _x_ < 0, then
+ 1. Set _s_ to *"-"*.
+ 1. Set _x_ to -_x_.
+ 1. If _x_ ≥ 1021, then
+ 1. Let _m_ be ! ToString(𝔽(_x_)).
+ 1. Else,
+ 1. Let _n_ be an integer for which _n_ / 10_fractionDigits_ - _x_ is as close to zero as possible. If there are two such _n_, pick the larger _n_.
+ 1. If _n_ = 0, let _m_ be *"0"*. Otherwise, let _m_ be the String value consisting of the digits of the decimal representation of _n_ (in order, with no leading zeroes).
+ 1. If _fractionDigits_ ≠ 0, then
+ 1. Let _k_ be the length of _m_.
+ 1. If _k_ ≤ _fractionDigits_, then
+ 1. Let _z_ be the String value consisting of _fractionDigits_ + 1 - _k_ occurrences of the code unit 0x0030 (DIGIT ZERO).
+ 1. Set _m_ to the string-concatenation of _z_ and _m_.
+ 1. Set _k_ to _fractionDigits_ + 1.
+ 1. Let _a_ be the first _k_ - _fractionDigits_ code units of _m_.
+ 1. Let _b_ be the other _fractionDigits_ code units of _m_.
+ 1. Set _m_ to the string-concatenation of _a_, *"."*, and _b_.
+ 1. Return the string-concatenation of _s_ and _m_.
+
+
+
+