Skip to main content

This is documentation for Caché & Ensemble. See the InterSystems IRIS version of this content.

For information on migrating to InterSystems IRIS, see the InterSystems IRIS Migration Guide and Migrating to InterSystems IRIS, both available on the WRC Distributions page (login required).


Converts a number from hexadecimal to decimal.




hexnum An expression that resolves to a positive hexadecimal integer. If hexnum contains only the characters 0 – 9, it may be specified as a number; if it includes the hexadecimal characters A – F, it must be specified as a string. The hexadecimal characters A – F are not case-sensitive.


The XTD function returns a hexadecimal integer converted to decimal. The hexnum value must be a positive hexadecimal integer. XTD returns the corresponding decimal integer value.

If hexnum is zero, a negative number, or a non-numeric string, XTD returns 0. If hexnum is a fractional number, it is truncated to its integer portion. If hexnum is a mixed numeric string, the hexadecimal part is parsed until a non-hexadecimal character is encountered. Thus “7Dwarves” is parsed as 7D. If hexnum is the null string, a <FUNCTION> error occurs.

Use DTX to convert from decimal to hexadecimal.


The following examples use the XTD function to return a decimal number:

PRINT XTD(12);        ! Returns 12
PRINT XTD("1C");      ! Returns 28
PRINT XTD("1c");      ! Returns 28
PRINT XTD("-1C");     ! Returns 0
PRINT XTD("red");     ! Returns 0
Copy code to clipboard

See Also