The toHex() function converts a decimal number to hexadecimal (base 16).
A String dec holds the number that is to be converted to hex.
Hexadecimal number.
To convert a number to hexadecimal, parseInt is used to parse a Number from the String dec.
The toString() method is called on this number with the radix 16.
The radix 16 in the call to the toString() method will convert a base 10 number
to a base 16 number (but as a String not a Number).
function toHex(dec){ var result= (parseInt(dec).toString(16)); if(result.length ==1) result= ("0" +result); return result.toUpperCase(); }
The toString() is a method of many different types of objects. Here it is
called on an instance of the Number object.
The radix parameter is an optional positive integer.
Specifying the radix parameter sets the base of the numbering system that
number is to be converted from (hexadecimal is base 16).
A String.