BitDtoX


The BitDtoX function converts a decimal number to a hexadecimal string representation.

Syntax

sHex = BitDtoX( nNumber )

bullet.gif    sHex is the hexadecimal form

bullet.gif    nNumber is the decimal integer number to convert.

Remarks

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.

Example

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.

n = 15

-- pick a number

Printf( "'%u --> %s'", BitDtoX( n ) )

-- prints 15 --> 0000000F

Printf( "'%u --> %s'", BitTrim( BitDtoX( n ) ) )

-- prints 15 --> F

Related Topics

Boolean Math Functions

BitXtoD

BitDtoB


Mira Pro x64 Script User's Guide, Copyright Ⓒ 2024 Mirametrics, Inc. All Rights Reserved.