[Logo]
Forums Register Login
Operator: & ^ |
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!
 

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;
Ahh...the order of precendence. Got it. Thanks!

This thread has been viewed 662 times.

All times above are in ranch (not your local) time.
The current ranch time is
Sep 20, 2018 20:48:33.