Web hosting contract - JavaScript Programmer’s Reference Example code: // Create a

JavaScript Programmer’s Reference Example code: // Create a number and then examine its source myNumber = new Number(1000); document.write(myNumber.toSource()); Number.toString() (Method) Return a string primitive version of an object. Availability: 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: aRadix A 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. . A missing radix is assumed to be base 10. . Octal numbers use a radix value of 8. . Hexadecimal numbers use a radix value of 16. . Binary numbers use a radix value of 2. 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() 1564

Leave a Reply