riryka 发表于 2017-03-09 22:47

为什么convert(int, 0x00000100)结果为65536呢

65536转换为16进制应该为0x10000.

chenfeng825 发表于 2017-03-31 12:27

Conversions between binary and integer types
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.

用hextoint
页: [1]
查看完整版本: 为什么convert(int, 0x00000100)结果为65536呢