博客园 :: 首页 :: 博问 :: 闪存 :: 新随笔 :: 联系 :: 订阅 订阅 :: 管理 ::

整数保留最高位

        number = ((number & 0xFFFF0000) != 0) ? (number & 0xFFFF0000) : (number & 0x0000FFFF);
        number = ((number & 0xFF00FF00) != 0) ? (number & 0xFF00FF00) : (number & 0x00FF00FF);
        number = ((number & 0xF0F0F0F0) != 0) ? (number & 0xF0F0F0F0) : (number & 0x0F0F0F0F);
        number = ((number & 0xCCCCCCCC) != 0) ? (number & 0xCCCCCCCC) : (number & 0x33333333);
        number = ((number & 0xAAAAAAAA) != 0) ? (number & 0xAAAAAAAA) : (number & 0x55555555);

 

posted on 2014-02-26 13:54  glshader  阅读(737)  评论(0编辑  收藏  举报