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.>>-X2D--(--hexstring--+------+--)------------------------------>< '-,--n-'
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.
X2D('0E') -> 14
X2D('81') -> 129
X2D('F81') -> 3969
X2D('FF81') -> 65409
X2D('c6 f0'X) -> 240 /* EBCDIC */
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.
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.