Gets a string representation of the Number object taking
into account the host locale.
Parameters |
Description |
radix |
A numbering system base in the range 2-16. Defaults
to 10. |
Return value |
Description |
string |
The string representation of the Number object. |
Usage
In radix 10, mixed numbers include the
decimal portion formatted according to the locale. In other radixes,
mixed numbers are truncated to integers.
Examples
This example prints three numbers
in string format first in radix 10 then in radix 16.
function p(stuff) {
print("<<<" + stuff + ">>>");
}
var integer : Number;
var fixed : Number;
var flot : Number;
try {
integer = new Number(54321);
fixed = new Number(543.21);
flot = new Number(54321E-2);
p(integer.toLocaleString()); // prints <<<54321.0>>>
p(fixed.toLocaleString()); // prints <<<543.21>>>
p(flot.toLocaleString()); // prints <<<543.21>>>
p(integer.toLocaleString(16)); // prints <<<d431>>>
p(fixed.toLocaleString(16)); // prints <<<21f>>>
p(flot.toLocaleString(16)); // prints <<<21f>>>
} catch(e) {
p("Error = " + e);
}