Advertisement
Stephen_MS

bitwise stuffs in J

Mar 17th, 2016
102
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 0.49 KB | None | 0 0
  1. short a = 3;                 // 00000000 00000011
  2. short b = 5;                 // 00000000 00000101
  3. System.out.println( a | b);  // 00000000 00000111 --> 7
  4. System.out.println( a & b);  // 00000000 00000001 --> 1
  5. System.out.println( a ^ b);  // 00000000 00000110 --> 6
  6. System.out.println(~a & b);  // 00000000 00000100 --> 4
  7. System.out.println( a << 1); // 00000000 00000110 --> 6
  8. System.out.println( a >> 1); // 00000000 00000001 --> 1
  9.  
  10. System.out.println(a < b ? "smaller" : "larger");
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement