Skip to content

InvisibleLeVen/number-to-decimal-form-string-x

 
 

Repository files navigation

Travis status Dependency status devDependency status npm version

number-to-decimal-form-string-x

Convert a base-10 or scientific E-notation value to a decimal form string.

Version: 1.0.1
Author: Xotic750 Xotic750@gmail.com
License: MIT
Copyright: Xotic750

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

var toDecimalFormString = require('number-to-decimal-form-string-x');

toDecimalFormString(Number.MIN_SAFE_INTEGER); // '-9007199254740991'
toDecimalFormString(-0); // '-0'

var number = 0.00000000001;
number.toString(); // '1e-11'
toDecimalFormString(number); // '0.00000000001'

number = 88259496234518.57;
number.toString(); '88259496234518.56'
toDecimalFormString(number); // '88259496234518.56'

toDecimalFormString(Math.PI); // '3.141592653589793'
toDecimalFormString(Number.MAX_SAFE_INTEGER); // '9007199254740991'

toDecimalFormString('0e+0'); // '0'
toDecimalFormString('1e-11'); // '0.00000000001'
toDecimalFormString('4.062e-3'); // '0.004062'
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

About

Convert a base-10 or scientific E-notation value to a decimal form string.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • JavaScript 98.2%
  • HTML 1.8%