aspose file tools*
The moose likes Beginning Java and the fly likes try out Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "try out" Watch "try out" New topic
Author

try out

Parameswaran Thangavel
Ranch Hand

Joined: Mar 01, 2005
Posts: 485
System.out.println(010^101);


i doubt how it got 109
any one please
Adam Czysciak
Ranch Hand

Joined: Feb 25, 2005
Posts: 82
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


Adam<br /> <br /><i>SCJA, SCJP 5.0, SCWCD 1.4, SCBCD 5, SCEA 5</i>
Amit Das
Ranch Hand

Joined: Mar 05, 2005
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
Sheriff

Joined: Sep 28, 2004
Posts: 18712
    
  40

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


Books: Java Threads, 3rd Edition, Jini in a Nutshell, and Java Gems (contributor)
Parameswaran Thangavel
Ranch Hand

Joined: Mar 01, 2005
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

Joined: Aug 03, 2002
Posts: 7729
Moving from SCJP to Java in General (Beginner).


Ask a Meaningful Question and HowToAskQuestionsOnJavaRanch
Getting someone to think and try something out is much more useful than just telling them the answer.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: try out