我怎么一点超过32位移位长? [英] How do I bit shift a long by more than 32 bits?
本文介绍了我怎么一点超过32位移位长?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
好像我应该能够超过32位提供移位左操作数是一个长期执行的C / C位的移位++。但是,这似乎并没有工作,至少与G ++编译器。
It seems like I should be able to perform bit shift in C/C++ by more than 32 bits provided the left operand of the shift is a long. But this doesn't seem to work, at least with the g++ compiler.
例如:
unsigned long A = (1L << 37)
给
A = 0
这不是我想要的。我缺少的东西,或者这是不可能的?
which isn't what I want. Am I missing something or is this just not possible?
-J
推荐答案
使用类型的变量 uint64_t中
(从 stdint重新尝试。 ^ h
)代替长
。 uint64_t中
保证是64位长,像您期望的行为应该。
Re-try this using a variable of type uint64_t
(from stdint.h
) instead of long
. uint64_t
is guaranteed to be 64 bits long and should behave as you expect.
这篇关于我怎么一点超过32位移位长?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文