• 博客园logo
  • 会员
  • 周边
  • 新闻
  • 博问
  • 闪存
  • 众包
  • 赞助商
  • Chat2DB
    • 搜索
      所有博客
    • 搜索
      当前博客
  • 写随笔 我的博客 短消息 简洁模式
    用户头像
    我的博客 我的园子 账号设置 会员中心 简洁模式 ... 退出登录
    注册 登录
ying_vincent
博客园    首页    新随笔    联系   管理    订阅  订阅
2014年2月25日
Algorithm: bit manipulation
摘要: 1. 一个数的从右起第p1位和第p2位swap n位 1 unsigned int swapBits(unsigned int x, unsigned int p1, unsigned int p2, unsigned int n) { 2 unsigned int set1 = (x >> p1) & ((1 > p2) & ((1 > (sizeof(int) * 8 - 1)));3 }also can use division4. count bit set in an integer1 int countsetbits(int x) {2 in 阅读全文
posted @ 2014-02-25 10:13 ying_vincent 阅读(198) 评论(0) 推荐(0)
博客园  ©  2004-2026
浙公网安备 33010602011771号 浙ICP备2021040463号-3