检查是否设置了n(大)位
我想检查是否设置了1024位(128个字节)中的任何一个。如果一切都很清楚,那么我想做一些事情。是否可以快速执行此操作,即一个指令,还是我必须循环浏览我的位图?
I want to check if any of the 1024 bits (128 bytes) are set. If all are clear, then I want to do something. Is it possible to do this quickly, i.e one instruction or do I have to loop through my bitmap?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
正如我所理解的问题,您想要检查是否有任何位是在您拥有的 1024 位中设置的。
假设您使用的是 64 位机器。
将位存储为
unit64_t
类型的数组,即8 字节
。所以你有这种类型的数组。
并检查您的钻头状况
As i have understood the questions, you want to check if any of the bit is set out of 1024 bits you have.
Assuming you are on 64 bit machine.
store the bits as array of
unit64_t
type which is8 bytes
.So you have array of this kind.
and to check your bit condition
检查是否有任何数据不为零。
设 buffer 为你要检查的数据,
Check whether any data is non zero.
Let buffer be the data you want to check,