i read the ecmascript 9.8.1 section ToString Applied to the Number Type, but i don't know what it means.
The operator ToString converts a number m to string format as follows:
If m is NaN, return the string "NaN".
If m is +0 or -0, return the string "0".
If m is less than zero, return the string concatenation of the string "-" and ToString(-m).
If m is infinity, return the string "Infinity".
Otherwise, let n, k, and s be integers such that k >= 1, 10k-1<= s <10k, the number value for s * 10n-k is m, and k is as small as possible. Note that k is the number of digits in the decimal representation of s, that s is not divisible by 10, and that the least significant digit of s is not necessarily uniquely determined by these criteria.
If k <= n <= 21, return the string consisting of the k digits of the decimal representation of s (in order, with no leading zeroes), followed by n k occurrences of the character '0'.
If 0 < n <= 21, return the string consisting of the most significant n digits of the decimal representation of s, followed by a decimal point '. ', followed by the remaining k-n digits of the decimal representation of s.
If -6 < n <= 0, return the string consisting of the character '0', followed by a decimal point '. ', followed by -n occurrences of the character '0', followed by the k digits of the decimal representation of s.
Otherwise, if k = 1, return the string consisting of the single digit of s, followed by lowercase character 'e', followed by a plus sign '+ ' or minus sign '-' according to whether n-1 is positive or negative, followed by the decimal representation of the integer abs(n-1) (with no leading zeros).
Return the string consisting of the most significant digit of the decimal representation of s, followed by a decimal point '. ', followed by the remaining k-1 digits of the decimal representation of s, followed by the lowercase character 'e', followed by a plus sign '+ ' or minus sign '-' according to whether n-1 is positive or negative, followed by the decimal representation of the integer abs(n-1) (with no leading zeros).
can somebody explain the algorithm to me or give me a blog about the ToString Applied to the Number Type?