diff --git a/src/main/java/com/never/BitOperation.java b/src/main/java/com/never/BitOperation.java new file mode 100644 index 0000000..05f6b50 --- /dev/null +++ b/src/main/java/com/never/BitOperation.java @@ -0,0 +1,23 @@ +package com.never; + +public class BitOperation { + public static void main(String[] args) { + int a = 2 ; + int b = ~a+1; + int c = b>>2; + int d = b>>>2; + printBit(a); + printBit(b); + System.out.println(b); + printBit(c); + printBit(d); + System.out.println(c); + System.out.println(d); + } + private static void printBit(int num){ + for(int i = 31; i >= 0; i--){ + System.out.print((num & (1<