忘记密码   免费注册 查看新帖 |

ChinaUnix.net

  平台 论坛 博客 文库 频道自动化运维 虚拟化 储存备份 C/C++ PHP MySQL 嵌入式 Linux系统
最近访问板块 发新帖
查看: 7511 | 回复: 1

为什么convert(int, 0x00000100)结果为65536呢 [复制链接]

论坛徽章:
0
发表于 2017-03-09 22:47 |显示全部楼层
65536转换为16进制应该为0x10000.

论坛徽章:
0
发表于 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
您需要登录后才可以回帖 登录 | 注册

本版积分规则

【重磅资料】多云网络实战的相关问题汇总!
云网融合的多云网络

本文介绍如何管理私有云数据中心,构建数据中心互联和混合云解决方案。对于OTT 网络架构的深入理解,基本上来源于SIGCOM 的白皮书和一些公开视频。

Overlay SDN 控制器详解

云计算为了适应业务/APP 的快速开发和部署,会把网络分为两层:Overlay 和 Underlay 网络。本文主要讲Overlay网络层面的问题。

超级核心路由器演进

2016 年,网络连接已经采用100G/200G/400G(虽然 400GE 接口技术还未成熟),互联网出口也已经增长到了 T 级别。

获得资料 >>
  

北京盛拓优讯信息技术有限公司. 版权所有 京ICP备16024965号 北京市公安局海淀分局网监中心备案编号:11010802020122
广播电视节目制作经营许可证(京) 字第1234号 中国互联网协会会员  联系我们:wangnan@it168.com
感谢所有关心和支持过ChinaUnix的朋友们 转载本站内容请注明原作者名及出处

清除 Cookies - ChinaUnix - Archiver - WAP - TOP