A: For converting a hexadecimal number to a decimal number, you use the
parseInt function with a radix of
16, like this:
Code:
var nDecimal=parseInt(sHexadecimal, 16);
where
sHexadecimal is a string containing a hexadecimal number.
For converting a decimal number to hexadecimal, you use the
toString method with an argument of the radix you want to convert to, in this case
16, like this:
Code:
var sHexadecimal=nDecimal.toString(16);
where
nDecimal is either a variable name, a number literal wrapped in parentheses, or a function giving a number as return value.