z/OS TSO/E REXX Reference
Previous topic | Next topic | Contents | Contact z/OS | Library | PDF


X2D (Hexadecimal to Decimal)

z/OS TSO/E REXX Reference
SA32-0972-00

Read syntax diagramSkip visual syntax diagram
>>-X2D(hexstring--+----+--)------------------------------------><
                  '-,n-'      

returns the decimal representation of hexstring. The hexstring is a string of hexadecimal characters. If the result cannot be expressed as a whole number, an error results. That is, the result must not have more digits than the current setting of NUMERIC DIGITS.

You can optionally include blanks in hexstring (at byte boundaries only, not leading or trailing) to aid readability; they are ignored.

If hexstring is null, the function returns 0.

If you do not specify n, hexstring is processed as an unsigned binary number.

Here are some examples:
X2D('0E')        
->    14
X2D('81')        ->    129
X2D('F81')       ->    3969
X2D('FF81')      ->    65409
X2D('F0')        ->    240
X2D('c6 f0'X)    ->    240          /* 'C6 F0'X is equivalent
                                       to'F0'.*/
                                    /* See discussion elsewhere of
                                       hexadecimal strings.*/
X2D('C6F0')      ->    61646        /* 'C6F0'is a 4 digit hex number.*/

If you specify n, the string is taken as a signed number expressed in n hexadecimal digits. If the leftmost bit is off, then the number is positive; otherwise, it is a negative number in two's complement notation. In both cases it is converted to a whole number, which may, therefore, be negative. If n is 0, the function returns 0.

If necessary, hexstring is padded on the left with 0 characters (note, not “sign-extended”), or truncated on the left to n characters.

Here are some examples:
X2D('81',2)      ->    -127
X2D('81',4)      ->    129
X2D('F081',4)    ->    -3967
X2D('F081',3)    ->    129
X2D('F081',2)    ->    -127
X2D('F081',1)    ->    1
X2D('0031',0)    ->    0

Implementation maximum: The input string may not have more than 500 hexadecimal characters that will be significant in forming the final result. Leading sign characters (0 and F) do not count towards this total.

Go to the previous page Go to the next page




Copyright IBM Corporation 1990, 2014