2.1.2 • Published 5 years ago
number-to-decimal-form-string-x v2.1.2
number-to-decimal-form-string-x
Convert a base-10 or scientific E-notation value to a decimal form string.
module.exports(value)
⇒ string ⏏
This method converts a base-10 or scientific E-notation value to
a decimal form string. Javascript's IEE 754 double-precision numbers
give the same precision as number.toString()
.
Kind: Exported function
Returns: string - The value converted to a decimal form string.
Throws:
- TypeError If value is not a valid format.
- TypeError If value is a Symbol or not coercible.
Param | Type | Description |
---|---|---|
value | number | string | The value to be converted. |
Example
import toDecimalFormString from 'number-to-decimal-form-string-x';
toDecimalFormString(Number.MIN_SAFE_INTEGER); // '-9007199254740991'
toDecimalFormString(-0); // '-0'
let number = 0.00000000001;
number.toString(); // '1e-11'
toDecimalFormString(number); // '0.00000000001'
number = 88259496234518.57;
console.log(number.toString()); // '88259496234518.56';
console.log(toDecimalFormString(number)); // '88259496234518.56'
console.log(toDecimalFormString(Math.PI)); // '3.141592653589793'
console.log(toDecimalFormString(Number.MAX_SAFE_INTEGER)); // '9007199254740991'
console.log(toDecimalFormString('0e+0')); // '0'
console.log(toDecimalFormString('1e-11')); // '0.00000000001'
console.log(toDecimalFormString('4.062e-3')); // '0.004062'
console.log(toDecimalFormString('4.461824e+2')); // '446.1824'
toDecimalFormString(NaN); // TypeError
toDecimalFormString(' 0'); // TypeError
toDecimalFormString('0 '); // TypeError
toDecimalFormString('0.'); // TypeError
toDecimalFormString('.0'); // TypeError
toDecimalFormString('0x1'); // TypeError
toDecimalFormString('0o1'); // TypeError
toDecimalFormString('0b1'); // TypeError
toDecimalFormString('4.062 e-3'); // TypeError
toDecimalFormString('9 007 199 254 740 991'); // TypeError
toDecimalFormString('9,007,199,254,740,991'); // TypeError
toDecimalFormString(Symbol('0')); // TypeError
toDecimalFormString(Object.create(null)); // TypeError
2.1.2
5 years ago
2.1.1
5 years ago
2.1.0
5 years ago
2.0.18
5 years ago
2.0.17
5 years ago
2.0.16
5 years ago
2.0.15
5 years ago
2.0.14
5 years ago
2.0.13
5 years ago
2.0.12
5 years ago
2.0.11
5 years ago
2.0.10
5 years ago
2.0.9
5 years ago
2.0.8
5 years ago
2.0.7
5 years ago
2.0.6
5 years ago
2.0.5
5 years ago
2.0.4
5 years ago
2.0.3
5 years ago
2.0.2
5 years ago
2.0.1
5 years ago
2.0.0
5 years ago
1.0.1
6 years ago
1.0.0
7 years ago