INTEGER_TO_HEX Function

Converts an integer to a string containing the hexadecimal representation.

Note: The hexadecimal output is in Little Endian format, suitable for creating tags in image files (e.g., DCOM, TIFF, JPEG, and so forth).

Usage

    result = INTEGER_TO_HEX(value)

Input Parameters

value—A scalar integer (BYTE, INT, INT32, LONG) to convert.

Returned Value

result—A string containing the hexadecimal representation. The length of the string depends on the input integer type.

Keywords

None.

Discussion

For input integers, which are BYTE, INT, INT32, and LONG data types, the number of hexadecimal digits in the returned string is 2, 4, 8, and 8 (in 32-bit PV‑WAVE) or 16 (in 64-bit PV‑WAVE), respectively. For example, if the number of hexadecimal digits converted from a positive INT is less than 4, PV‑WAVE prepends a '0' to the hexadecimal digits. If the input is a negative INT, PV‑WAVE prepends an 'F'.

Example

Input integers in the example are BYTE, INT, INT32, and LONG.

x = 56B
PRINT, INTEGER_TO_HEX(x),"   ",  INTEGER_TO_HEX(-x)
; PV-WAVE prints: 38   C8

x = 2^15 - 1	
PRINT, INTEGER_TO_HEX(x),"   ",  INTEGER_TO_HEX(-x)
; PV-WAVE prints: 7FFF   8001

x = 2i^15 - 1	
PRINT, INTEGER_TO_HEX(x),"   ",  INTEGER_TO_HEX(-x)
; PV-WAVE prints: 00007FFF   FFFF8001

x = 2L^15 - 1	
PRINT, INTEGER_TO_HEX(x),"   ",  INTEGER_TO_HEX(-x)
; PV-WAVE prints: 00007FFF   FFFF8001 in 32-bit PV-WAVE
; PV-WAVE prints: 0000000000007FFF   FFFFFFFFFFFF8001 in 64-bit PV-WAVE

See Also

CONVERT_BASE, BYTESWAP