How Small Can A Javascript Number Be Without Displaying In Scientific Notation?
I've made some code that rounds off a number to a given number of decimal places but will use more places when there is underflow to avoid rounding just to zero, which wouldn't be
Solution 1:
There are a few reasons the number is displayed in scientific notation:
- If the length of significant digits in the number is greater than 21.
- If the number of zeros before a nonzero number is greater than 6. (e.g. 0.00000001)
The conversion to scientific notation in numbers is specified in Section 9.8.1 of ECMA-262.
An implementation of this specification can be found in the V8 engine here.
Post a Comment for "How Small Can A Javascript Number Be Without Displaying In Scientific Notation?"