# try out

Parameswaran Thangavel
Ranch Hand
Posts: 485
System.out.println(010^101);

i doubt how it got 109

Ranch Hand
Posts: 90
5
Originally posted by Parameswaran Thangavel:
System.out.println(010^101);

i doubt how it got 109

010=8(dec) = 1000(bin)
101=101(dec)=64+32+4+1=1100101(bin)
1000 ^ 1100101 = 1101101 = 64+32+8+4+1 = 109
should be clear now

Amit Das
Ranch Hand
Posts: 206

010=8(dec) = 1000(bin)
101=101(dec)=64+32+4+1=1100101(bin)

how did you come to the conclusion that 010=8
and 101=101(dec)???

Henry Wong
author
Marshal
Posts: 21489
84
Originally posted by Amit Das:

how did you come to the conclusion that 010=8
and 101=101(dec)???

There is nothing to conclude. You just have to know that...

In Java, Literals that begin with 0 are considered octal. Literals that begin with 0x are considered hex, and the rest are assumed decimal.

Henry

Parameswaran Thangavel
Ranch Hand
Posts: 485
hi can any one explain the order in which the expressions are executed

system.out.println(101&110|001)

is it from left to right or right to left

Barry Gaunt
Ranch Hand
Posts: 7729
Moving from SCJP to Java in General (Beginner).

 Did you see how Paul cut 87% off of his electric heat bill with 82 watts of micro heaters?