Javascript examples for Number:toExponential
The toExponential() method converts a number into an exponential notation.
number.toExponential(x);
Parameter | Description |
---|---|
x | Optional. An integer between 0 and 20 representing the number of digits after the decimal point. |
A String, representing the number as an exponential notation
The following code shows how to Convert a number into an exponential notation:
<!DOCTYPE html> <html> <body> <button onclick="myFunction()">Test</button> <p id="demo"></p> <script> function myFunction() {/*from www. j av a 2 s. c o m*/ var num = 52.56789321123; var n = num.toExponential(3); document.getElementById("demo").innerHTML = n; } </script> </body> </html>