小编use*_*460的帖子

用C中的按位运算符分隔字节中的Nybbles

如果我们有一个十进制值:123
及其二进制版本:01111011

如何从该字节中将最左边的四个和最右边的四个位变为两个独立的int变量?

我的意思是:

int a = 7;  // 0111 (the first four bits from the left)
int b = 11; // 1011 (the first four bits from the right)
Run Code Online (Sandbox Code Playgroud)

非常感激!

c bits bit-manipulation

2
推荐指数
1
解决办法
2500
查看次数

标签 统计

bit-manipulation ×1

bits ×1

c ×1