Number.toString() (Method)

Return a string primitive version of an object.


ECMAScript edition - 2
JavaScript - 1.1
JScript - 1.0
Internet Explorer - 3.02
Netscape - 3.0
Opera - 3.0
Property/method value type:String primitive
JavaScript syntax:-myNumber.toString(aRadix)
Argument list:aRadixA radix to base the string conversion of the value on.

The result of this method is a String primitive representation of the numeric value, of the receiving object, rendered according to the passed-in radix value.

A radix is the number of discrete values in the counting sequence before a carry over digit is generated. Thus, the radix of decimal numbers is 10. With this mechanism, you can generate values to any radix. The radix is also called the base of the number system.

The radix value is in the range 2 to 36 and allows the numeric value to be reproduced in a variety of number bases.

For an example, refer to the Decimal value topic where this is used to generate a lookup table.

Before the radix conversion was available, this method simply converted to a string, which most commentators considered was unnecessary since JavaScript did this naturally without any need to add special scripting support. However, now that we can convert numeric values from one base to another, this function becomes far more useful.

See also:Cast operator, Decimal value, Hexadecimal value, Number.prototype, Number.toExponential(), Number.toFixed(), Octal value, toString()


ECMA 262 edition 2 - section -

ECMA 262 edition 3 - section -