Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
什么&时候工作
&
int num1=10,num2=9; int res=num1 & num2; // where num1 and num2 are integers
res=8;它是如何工作的价值
res=8;
是&按位与运算符。只有在 num1和num2中都设置了相应的位时,结果中的每个位才会被设置。
如果你用二进制写数字可能更有意义:
num1 1010 = 10 num2 1001 = 9 ------------------------ num1 & num2 1000 = 8