Skip to main content

This is documentation for Caché & Ensemble.

For information on converting to InterSystems IRIS, see the InterSystems IRIS Adoption Guide and the InterSystems IRIS In-Place Conversion Guide, both available on the WRC Distributions page (login required).

Previous sectionNext section


Returns a string representing the hexadecimal value of a number.




The number argument is any valid expression that resolves to a positive or negative number. If number is a decimal fraction, it is truncated to a whole number before being evaluated.


The Hex function converts a number from decimal (base 10) to hexadecimal (base 16). To convert a number from hexadecimal to decimal, represent hexadecimal numbers directly by preceding numbers in the proper range with &H For example, &H10 is the hexadecimal notation for decimal 16.

If Number Is Hex Returns
Empty Zero (0).
Any other number Up to eight hexadecimal characters.


The following example uses the Hex function to return the hexadecimal value of a decimal (base-10) number:

Println Hex(0)     ' Returns 0.
Println Hex(4)     ' Returns 4.
Println Hex(10)    ' Returns A.
Println Hex(16)    ' Returns 10.
Println Hex(459)   ' Returns 1CB.
Copy code to clipboard

The following example uses the &H prefix to return the decimal (base-10) value for a hexadecimal number:

Println &H000  ' Returns 0.
Println &H4    ' Returns 4.
Println &HA    ' Returns 10.
Println &H10   ' Returns 16.
Copy code to clipboard

See Also