Caché Basic Reference
Hex
[Back] [Next]
   
Server:docs2
Instance:LATEST
User:UnknownUser
 
-
Go to:
Search:    

Returns a string representing the hexadecimal value of a number.
Synopsis
Hex(number)
Arguments
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.
Description
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.
Examples
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.
 
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.
 
See Also