%HEX

Return a hexadecimal string representation of a numeric value

WSupported on Windows
USupported on Unix
VSupported on OpenVMS
NSupported in Synergy .NET
string = %HEX(value[, magnitude])

Return value

string

A hexadecimal, uppercase ASCII digit string representation of value. (a)

Arguments

value

The value to be converted to a hexadecimal, ASCII representation. (n)

magnitude

(optional) A value that determines the number of characters in the returned string, as follows: (n)

1 = 2-character string

2 = 4-character string

4 = 8-character string

8 = 16-character string

Discussion

%HEX converts a decimal data value to a 32-bit longword value.

If magnitude is not present or if it contains a value other than 1, 2, 4, or 8, the resulting string is eight characters long (if value can be represented in 32 bits) or sixteen characters long (if value cannot be represented in 32 bits).

Examples

The following code fragment compares data from two files. One has data stored in ASCII format, the other in hexadecimal.

if (%hex(ascval, 1) .eq. hexval) 

The code fragment below checks for a specific hexadecimal value in the ASCII data.

if (%hex(ascval, 1) .eq. 'F')