Product SiteDocumentation Site

7.4.22. D2X (Decimal to Hexadecimal)


>>-D2X(wholenumber--+----+--)----------------------------------><
                    +-,n-+

Returns a string, in character format, that represents wholenumber, a decimal number, converted to hexadecimal. The returned string uses uppercase alphabetics for the values A-F and does not include whitespace characters.
Wholenumber must not have more digits than the current setting of NUMERIC DIGITS.
If you specify n, it is the length of the final result in characters. After conversion the input string is sign-extended to the required length. If the number is too big to fit n characters, it is truncated on the left. n must be a positive whole number or zero.
If you omit n, wholenumber must be a positive whole number or zero, and the returned result has no leading zeros.
Here are some examples:

Example 7.29. Builtin function D2X

D2X(9)         ->    "9"
D2X(129)       ->    "81"
D2X(129,1)     ->    "1"
D2X(129,2)     ->    "81"
D2X(129,4)     ->    "0081"
D2X(257,2)     ->    "01"
D2X(-127,2)    ->    "81"
D2X(-127,4)    ->    "FF81"
D2X(12,0)      ->    ""