public interface JSNumberFunctions extends JSObjectFunctions
hasOwnProperty| Modifier and Type | Method and Description |
|---|---|
JSString |
toExponential(JSNumber fractionDigits)
function toExponential(fractionDigits) format a number using exponential notation.
|
JSString |
toFixed(JSNumber fractionDigits)
function toFixed(fractionDigits) format a number using fixed-point notation.
|
JSString |
toPrecision(JSNumber fractionDigits)
function toPrecision(precision) format the significant digits of a number.
|
hasOwnProperty, isPrototypeOf, propertyIsEnumerable, toLocaleString, toString, valueOfJSString toFixed(JSNumber fractionDigits)
Example
var n = 12345.6789; n.toFixed(); //returns 12346: note rounding up n.toFixed(1); //returns 12345.7: note rounding up n.toFixed(6); //returns 12345.678900: note zeros (1.23e+20).toFixed(2); //returns 123000000000000000000.00
fractionDigits - The number of digits to appear after the decimal point. If omitted it is treated as 0.NumberJSString toExponential(JSNumber fractionDigits)
Example
var n = 12345.6789; n.toExponential(1); //returns 1.2e+4 n.toExponential(5); //returns 1.23457e+4 n.toExponential(10); //returns 1.2345678900e+4 n.toExponential(); //returns 1.23456789e+4
fractionDigits - The number of digits that appear after the decimal point.NumberJSString toPrecision(JSNumber fractionDigits)
Example
var n = 12345.6789; n.toPrecision(1); //returns 1e+4 n.toPrecision(3); //returns 1.23e+4 n.toPrecision(5); //returns 12346 n.toPrecision(10); //returns 12345.67890
fractionDigits - The number of significant digits to appear in the returned string.Number