The bitwise AND operator (&) compares each bit of the operands. In this case, 5 (binary 101) & 3 (binary 011) results in binary 001, which is 1 in decimal.
The bitwise XOR operator (^) compares each bit and returns 1 if the bits are different. 6 (binary 110) ^ 3 (binary 011) results in binary 101, which is 5 in decimal.
The bitwise NOT operator (~) flips each bit of the operand. ~7 in binary is 111...111000, which is -8 in decimal due to two's complement representation.
The bitwise left shift operator (<<) shifts the bits of the first operand to the left by the number of positions specified by the second operand. x << y results in 101000, which is 20 in decimal.
The bitwise right shift operator (>>) shifts the bits of the first operand to the right by the number of positions specified by the second operand. 8 >> 2 results in binary 10, which is 2 in decimal.
7.
Given x = 9 and y = 4, what is the value of x >>> y?
The unsigned right shift operator (>>>) shifts the bits to the right. Unlike >>, >>> fills the vacant bits with 0. So, 9 >>> 4 results in 0001, which is 1 in decimal.
The bitwise AND operator (&) compares each bit of the operands. In this case, 11 (binary 1011) & 3 (binary 0011) results in binary 0011, which is 3 in decimal.
The bitwise NOT operator (~) flips each bit of the operand. ~12 in binary is 1111...1110011, which is -13 in decimal due to two's complement representation.