在在C号位互换 [英] Swap bits in a number in C
本文介绍了在在C号位互换的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
在C采访中,有人问我的最后4位换一个号码的第4位。 (例如,1011 1110应该是1110 1011。)
In a C interview, I was asked to swap the first 4-bits of a number with the last 4 bit. (eg. 1011 1110 should be 1110 1011.)
有没有人有办法解决这个?
Does anyone have a solution for this?
推荐答案
如果你还没有见过或做了很多位操作,一个很好的资源,研究的是:
If you haven't seen or done much bit twiddling, a good resource to study is:
- Bit Twiddling Hacks
这篇关于在在C号位互换的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文