Win a copy of Mesos in Action this week in the Cloud/Virtualizaton forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

try out

 
Parameswaran Thangavel
Ranch Hand
Posts: 485
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
System.out.println(010^101);


i doubt how it got 109
any one please
 
Adam Czysciak
Ranch Hand
Posts: 90
5
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Originally posted by Parameswaran Thangavel:
System.out.println(010^101);


i doubt how it got 109
any one please


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
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

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
Pie
Posts: 21117
78
C++ Chrome Eclipse IDE Firefox Browser Java jQuery Linux VI Editor Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Moving from SCJP to Java in General (Beginner).
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic