小编Mur*_*uru的帖子

C将int转换为bitshift运算符

我只能使用这些符号:

!〜&^ | + << >>

这是我需要实现的表:

input | output
--------------
0     |   0
1     |   8
2     |   16
3     |   24
Run Code Online (Sandbox Code Playgroud)

随着输出我将左移32位int.

防爆.

int main()
{
   int myInt = 0xFFFFFFFF;
   myInt = (x << (myFunction(2)));

  //OUTPUT = 0xFFFF0000
}

int myFunction(int input)
{ 
   // Do some magic conversions here
}
Run Code Online (Sandbox Code Playgroud)

有任何想法吗????

c logic bit-manipulation

-1
推荐指数
1
解决办法
134
查看次数

标签 统计

bit-manipulation ×1

c ×1

logic ×1