Four Bitwise Results
Easyjava
Read two non-negative integers a and b and print four bitwise results.
Input: two integers separated by whitespace.
Output: four lines:
AND: <a & b>
OR: <a | b>
XOR: <a ^ b>
Left Shift: <a << 1>Example 1
Input
5 3
Output
AND: 1 OR: 7 XOR: 6 Left Shift: 10
- 0 <= a, b <= 1000000
Hint 1
Wrap each bitwise expression in parentheses when concatenating with a String.
Hint 2
a << 1 shifts a's bits one place to the left.
Apply &, |, ^ to the two numbers bit by bit, and << to shift a left by one bit (doubling it). Parentheses are needed so the + concatenation does not bind first.