操作符
说明
&
与
|
或
^
异或
<<
左移(右边补0)乘2
>>>
逻辑右移(左边补0)无符号除2
>>
算数右移(左边补符号位)除2
https://www.interviewcake.com/concept/java/bit-shiftarrow-up-right
LeetCode:
用 a &= -a 来取出最右端为 ‘1’ 的位
https://www.cser.club/leetcode/#/leetcode/260.SingleNumberIIIarrow-up-right
Most elegant way to change 0 to 1 and vice versaarrow-up-right
异或1,或者 做减法
或者
Last updated 5 years ago
0 ^ 1 = 1; 1 ^ 1 = 0;
i = 1 - i;