Convert decimal to other hexadecimal
Objectname. tostring ([Radix])
- Objectname is required. The object to be represented by a string.
- Radix is optional. Specifies the hexadecimal format when the numeric value is converted to a string.
Returns the string representation of an object.
VaR M = 10;
Document. Write (M. tostring (2) + "<br>"); // 1010
Document. Write (M. tostring (8) + "<br>"); // 12
Document. Write (M. tostring (10) + "<br>"); // 10
Document. Write (M. tostring (16) + "<br>"); // It is displayed as a, note that it is in lower case.
The minimum value of Radix is 2 and the maximum value is 36 (expressed by 10 digits and 26 English letters ).
Convert others to decimal
Parseint (numstring, [Radix])
- Numstring is required. String to be converted to a number.
- Radix is optional. Between 2 and 36, it indicates the hexadecimal value of the number saved by numstring. If this parameter is not provided, the string prefixed with '0x 'is treated as hexadecimal, and the string prefixed with '0' is treated as octal. All other strings are treated as decimal.
Returns an integer converted from a string.
Document. Write (parseint (1010, 2) + "<br>"); // 10
Document. Write (parseint (12, 8) + "<br>"); // 10
Document. Write (parseint (10, 10) + "<br>"); // display as 10
Document. Write (parseint ("A", 16) + "<br>"); // The value is 10.
Document. Write (parseint ("A", 16) + "<br>"); // The value is 10.
From: http://www.cftea.com/c/2009/04/OY8JV5J7JDFYZ0UZ.asp