wood burning stoves 2.0*
The moose likes Java in General and the fly likes Operator:  & ^ | Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of EJB 3 in Action this week in the EJB and other Java EE Technologies forum!
JavaRanch » Java Forums » Java » Java in General
Bookmark "Operator:  & ^ |" Watch "Operator:  & ^ |" New topic
Author

Operator: & ^ |

Shannon Sims
Ranch Hand

Joined: Jul 03, 2003
Posts: 197
I'm confused!!! I have compiled this code and I don't get the same results manually. Can someone please explain the following:
n = 7;
n = n & n + 1 | n + 2 ^ n + 3;
n = 57;
Here's how I'm figuring this out:
n = 7;
n = ( n & n ) + ( 1 | n ) + ( 2 ^ n ) + 3;
n = 56 + 57 + 58 + 3;
n = 174;
So, why isn't this right?
Thanks for the help!
Maverick Lasa
Greenhorn

Joined: Oct 18, 2003
Posts: 23
Originally posted by Shannon Sims:

n = 7;
n = n & n + 1 | n + 2 ^ n + 3;

this will be executed as:

refer to Java Expressions
mavedrive;
Shannon Sims
Ranch Hand

Joined: Jul 03, 2003
Posts: 197
Ahh...the order of precendence. Got it. Thanks!
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Operator: & ^ |
 
Similar Threads
assignment with & ...
Implementing recursive relations
A So Strange question !!(scjp07-Q108)
Is there an easy way to remember the operatos precedence?
Fibonacci Sum