lowbit()

版权声明:本文为博主原创文章,未经博主允许不得转载。 https://blog.csdn.net/han_hhh/article/details/82432316

lowbit()函数用来取一个二进制最低位的一与后边的0组成的数

例:5(101),lowbit(5)=1(1)

       12(1100),lowbit(12)=4(100)

int lowbit(int t)
{
    return t&(-t);
}

原理,二进制数的负数是正数取反加一

12(1100),-12(0100)

猜你喜欢

转载自blog.csdn.net/han_hhh/article/details/82432316