The binary and varbinary types store hexadecimal-like data consisting of a “0x” prefix followed by a string of digits and letters.
These strings are interpreted differently by different platforms. For example, the string “0x0000100” represents 65536 on machines that consider byte 0 most significant (little-endian) and 256 on machines that consider byte 0 least significant (big-endian).
Binary types can be converted to integer types either explicitly, using the convert function, or implicitly. If the data is too short for the new type, it is stripped of its “0x” prefix and zero-padded. If it is too long, it is truncated.
Both convert and the implicit datatype conversions evaluate binary data differently on different platforms. Because of this, results may vary from one platform to another. Use the hextoint function for platform-independent conversion of hexadecimal strings to integers, and the inttohex function for platform-independent conversion of integers to hexadecimal values. Use the hextobigint function for platform-independent conversion of hexadecimal strings to 64-bit integers, and the biginttohex function for platform-independent conversion of 64-bit integers to hexadecimal values.
Copyright © 2005. Sybase Inc. All rights reserved. |