How to convert exponential to number and number to exponential in javascript with Example
37629 Views
ToExponential() and toPrecision()
Number.prototype.toExponential() and Number.prototype.toPrecision() methods used to cast number to exponential and exponential to number accordingly.
Example
var number = 1982.3849;
//Convert number to exponential in javascript toExponential method
document.write(number.toExponential()+"<br />");
var expNumber = 1.9823849e+3;
//Convert exponential value to number
document.write(expNumber+"<br />");
document.write(expNumber.toPrecision()+"<br />");