+ 1

Give the output of the following. int x=13^3&8; System.out.println(x); Please show the process.

24th Feb 2017, 6:24 PM
Arghyadeep Ghosh
Arghyadeep Ghosh - avatar
2 odpowiedzi
+ 3
Bitwise operations. 13 = 1101 3 = 0011 8 = 1000 bitwise and & has higher precedence so it is done 1st 3 & 8 0011 1000 -------- 0000 = 0 next bitwise xor ^ 13 ^ 0 1101 0000 -------- 1101 = 13
24th Feb 2017, 7:06 PM
ChaoticDawg
ChaoticDawg - avatar
+ 1
The expression 13^3&8 is 13 'XOR'ed with 3 bit 'AND'ed with 8. But bit 'AND' has higher precedence than 'XOR', so that is processed 1st: 3&8 has result 0. Then 13^0 has result 13. Final result is 13.
24th Feb 2017, 7:10 PM
Ettienne Gilbert
Ettienne Gilbert - avatar