From http://www.w3schools.com (Copyright Refsnes Data)
JavaScript Number Object
The toPrecision() method formats a number to a specified length.
A decimal point and "0"s are added (if needed), to create the specified length.
| NumberObject.toPrecision(digits) |
| Parameter | Description |
|---|---|
| digits | Required. The number of digits |
ExampleIn this example we will change number of digits for a number:
The output of the code above will be: Try it yourself » |
JavaScript Number Object
From http://www.w3schools.com (Copyright Refsnes Data)