We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent 931da82 commit fd070fbCopy full SHA for fd070fb
src/main/java/com/bit/BitDemo.java
@@ -24,6 +24,12 @@ public class BitDemo {
24
*
25
* 所以可以得出0000,故输出的是0。
26
27
+ *
28
+ * 1是0001,其他数跟 1做与运算,都只看最后一位即可,其他的都是0。
29
+ * 8&1,就是二进制1000和0001的与运算,结果得到 0000
30
+ * 7&1,就是二进制0111和0001的与运算,结果得到 0001。
31
+ * 某一个数x, x & 1 可以得到 x 除以 2 的余数。也就是说,可以用 x & 1 来判断奇偶数。
32
33
*/
34
public static void andDemo(int num1, int num2) {
35
int result = num1 & num2;
0 commit comments