Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
我想做一个简单的位掩码操作。让我们说
uint64_t a = 348659235483;
假设这个数字被转换为二进制,我想提取从第 6 位到第 12 位的值(0 是右端的 MSB)。最小的代码是什么?
二进制是
10100010010110110110101101/110101/0011011
所以我想保存110101哪个是53
110101
53
怎么样
uint64_t a = 348659235483; uint64_t result = (a & 0x0fe0) >> 6;