小编Sin*_*acı的帖子

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

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

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)

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

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

c operators ampersand

-2
推荐指数
1
解决办法
97
查看次数

标签 统计

ampersand ×1

c ×1

operators ×1