首页 > 其他 > 详细

bit操作 转

时间:2015-03-14 12:22:20      阅读:302      评论:0      收藏:0      [点我收藏+]

http://www.catonmat.net/blog/low-level-bit-hacks-you-absolutely-must-know/

 

Bit Hack #6. Turn off the rightmost 1-bit.

y = x & (x-1)

Bit Hack #7. Isolate the rightmost 1-bit.

y = x & (-x)

Bit Hack #8. Right propagate the rightmost 1-bit.

y = x | (x-1)

Bit Hack #9. Isolate the rightmost 0-bit.

y = ~x & (x+1)

Bit Hack #10. Turn on the rightmost 0-bit.

y = x | (x+1)

bit操作 转

原文:http://www.cnblogs.com/huashiyiqike/p/4337284.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!