Turn off the rightmost set bit
来源:互联网 发布:淘宝50字通用好评 编辑:程序博客网 时间:2024/05/15 02:19
reference:
http://www.geeksforgeeks.org/turn-off-the-rightmost-set-bit/
Problem Definition:
Write a C function that unsets the rightmost set bit of an integer.
Solution:
Let the input number be n. n-1 would have all the bits flipped after the rightmost set bit (including the set bit). So, doing n&(n-1) would give us the required result.
Code:
/* unsets the rightmost set bit of n and returns the result */int fun(unsigned int n){ return n&(n-1);}
- Turn off the rightmost set bit
- Position of rightmost set bit
- How to turn off the Javadoc hover
- FZU 1704 Turn off the light
- FZU 1704 Turn off the light
- FZUOJ 1704 Turn off the light (高斯消元+大数高精度)
- 关灯看视频(Turn Off the Lights)
- Educational Codeforces Round 29 E. Turn Off The TV
- turn on/off webcache
- Turn on/off monitor
- turn off x-window
- turn on/off xwindow
- Turn off digital signature [Windows 64bit OS test driver数字签名出错的解法]
- The Byrds - Turn! Turn! Turn!
- Set Off
- Set Off
- Turn off Windows10 automatic updates
- Turn off cache of Thumdbs.db to prevent the move blocking from it in automation
- Android动画学习笔记-Android Animation
- Android 应用程序之间数据共享—ContentResolver
- Mac上锁屏的快捷键设置
- ArcGIS Server REST API(收藏教程)
- 单片机之旅——拓展的IO接口8255A
- Turn off the rightmost set bit
- Multiply a given Integer with 3.5
- Windows环境下WAMP + MantisBT的架设
- SSH配置(一)-struts2(convention插件零配置)
- Add 1 to a given number
- 黑马程序员_IO(下)
- QQ大文件为何上传这么快
- JVM垃圾收集算法
- SCI简介 引文数据分析和同行评估