使用与&减号运算符实现的符号(&)有什么作用?

Sin*_*acı -2 c operators ampersand

我正在准备编程竞赛,我偶然发现了下面的问题.

void main(){
    int number, result;
    scanf("%d",&number);
    result=number-(number&-number); //this is what i'm struggling to understand
    printf("%d",result);  
}
Run Code Online (Sandbox Code Playgroud)

请注意在注释行中使用"& - ".我无法弄清楚它的功能.我尝试使用谷歌搜索和逆向工程,但我找不到任何东西.

此外,问题本身并不是关于确切的输出,因为变量"数字"是动态的.我只需要了解"& - "部分的作用.谢谢!

Lee*_*ker 6

这是一个二元AND运算符.该表达式x & -x除了数字x中最右边的1位之外的所有内容都清零.然后x - (x & -x)只将该位置零,因此结果是原始数字,最右边的1位清零.