Caché MultiValue Basic Reference
XTD
[Home] [Back] 
InterSystems: The power behind what matters   
Class Reference   
Search:    

Converts a number from hexadecimal to decimal.
Synopsis
XTD(hexnum)
Arguments
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.
Description
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.
Examples
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
See Also