Coder Social home page Coder Social logo

xotic750 / number-to-decimal-form-string-x Goto Github PK

View Code? Open in Web Editor NEW
1.0 2.0 3.0 2.03 MB

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

License: MIT License

JavaScript 100.00%
javascript nodejs browser base10 e-notation scientific-notation number decimal-form tostring

number-to-decimal-form-string-x's Introduction

Travis status Dependency status devDependency status npm version jsDelivr hits bettercodehub score Coverage Status

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

number-to-decimal-form-string-x's People

Contributors

xotic750 avatar

Stargazers

 avatar

Watchers

 avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.