For conversion results that are reliable across platforms, use the hextoint and inttohex functions.
Similar functions, hextobigint and biginttohex, are available for converting 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. The following are all valid uses of hextoint:
select hextoint("0x00000100FFFFF") select hextoint("0x00000100") select hextoint("100")
hextoint strips it of the “0x” prefix. If the data exceeds 8 digits, hextoint truncates it. If the data is less 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 which platform you are using.
Copyright © 2005. Sybase Inc. All rights reserved. |