Contents | Index | < Browse | Browse >
usage: X2D(string,digits)

-converts a hexadecimal number to decimal
-the digits arguments specifies the number of rightmost hex digits used in the conversion.
-digits argument cannot be greater than 8.
-see also numeric digits and d2x()

The ARexx reference manual does not explain the digits argument. Other references say digits sets the length of the hex string used for conversion, and the string is truncated or padded with 0's on the left if longer or shorter than string. But the latter suggestion doesn't appear to work that way. However, a conversion from decimal to hex with the d2x() function is padded with zeros.

Following example illustrates the action that takes place with/without the digits argument ( "--->" denotes the result):

say x2d(0a4452) ---> 672850
say x2d(0A4452,0) ---> 0
say x2d(0A4452,1) ---> 2
say x2d(0A4452,2) ---> 82
say x2d(0A4452,3) ---> 1106
say x2d(0A4452,4) ---> 17490
say x2d(0A4452,5) ---> -375726
say x2d(0A4452,6) ---> 672850
say x2d(0A4452,7) ---> 672850
say x2d(0A4452,8) ---> 672850
say x2d(0A4452,9) ---> "Invalid argument to function" error message

Comments welcome. [see About ]

1)"The string may contain max. 8 digits because it's a 32 bit value." ­stefan.haubenthal@web.de