BitDtoX
The BitDtoX function converts a decimal number to a hexadecimal string representation.
sHex = BitDtoX( nNumber ) |
The conversion is returned with all characters present, including leading 0's. For example, the hexadecimal representation of a 32-bit integer will always be returned using 8 characters even if most of the high-order bits are 0. To reduce the string length, you can use the BitTrim function to strip all leading 0's from the hexadecimal string.
The following script converts a decimal number to a hexadecimal string representation. Note that the decimal number is printed using %u because it is considered an unsigned (i.e., 0 or positive) integer.
|
-- pick a number |
|
-- prints 15 --> 0000000F |
|
-- prints 15 --> F |