Convert Hexadecimal Data

For conversion results that are reliable across platforms, use the hextoint and inttohex functions.

Similar functions, hextobigint and biginttohex, are available to convert to and from 64-bit integers.

hextoint accepts literals or variables consisting of digits and the uppercase and lowercase letters A – F, with or without a “0x” prefix. These are all valid uses of hextoint:

select hextoint("0x00000100FFFFF")
select hextoint("0x00000100")
select hextoint("100")

hextoint strips data of the “0x” prefix. If the data exceeds 8 digits, hextoint truncates it. If the data is fewer than 8 digits, hextoint right-justifies and pads it with zeros. Then hextoint returns the platform-independent integer equivalent. The above expressions all return the same value, 256, regardless of the platform that executes the hextoint function.

The inttohex function accepts integer data and returns an 8-character hexadecimal string without a “0x” prefix. inttohex always returns the same results, regardless of platform.