如何在C/C++中设置,清除和切换?
c c++ bit-manipulation bitwise-operators
我不想优化任何东西,我发誓,我只想出于好奇而问这个问题.我知道,在大多数硬件有位移(例如的组件的命令shl,shr),它是一个命令.但是,你转移了多少比特(纳秒级,或CPU技巧)是否重要?换句话说,在任何CPU上是否更快?
shl
shr
x << 1;
和
x << 10;
请不要因为这个问题而恨我.:)
c c++ cpu performance low-level
c ×2
c++ ×2
bit-manipulation ×1
bitwise-operators ×1
cpu ×1
low-level ×1
performance ×1