整数位运算相关操作

整数保留最高位

        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);
原文地址:https://www.cnblogs.com/glshader/p/3569140.html