Gets a string representation of a number using exponential
(scientific) notation.
Parameters |
Description |
precision |
The number of decimal places in the fractional
part of the notation. Defaults to 0. |
Return value |
Description |
string |
The string value of the number in exponential
notation. |
Examples
This example prints a number in exponential
format with various precisions.
function p(stuff) {
print("<<<" + stuff + ">>>");
}
var n : Number;
try {
n = new Number(543.21);
p(n.toExponential(0)); // Prints <<<5E2>>>
p(n.toExponential(1)); // Prints <<<5.4E2>>>
p(n.toExponential(2)); // Prints <<<5.43E2>>>
p(n.toExponential(3)); // Prints <<<5.432E2>>>
p(n.toExponential(4)); // Prints <<<5.4321E2>>>
} catch(e) {
p("Error = " + e);
}