[英]How to shift >= 32 bits in uint64_t?
以下代码触发gcc
警告(gcc 4.2.1):
#include <boost/cstdint.hpp>
boost::uint64_t x = 1 << 32; // warning: left shift count >= width of type
不应该没问题,因为该类型有64位?
如何在
uint64_t
移位> = 32位?
如果您的编译器支持long long
:
boost::uint64_t x = 1LL << 32;
除此以外:
boost::uint64_t x = boost::uint64_t(1) << 32;
不应该没问题,因为该类型有64位?
不。即使x
是64位, 1
也不是。 1
是32位。 如何使用结果不会影响结果的生成方式。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.