[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 680 times.

All times above are in ranch (not your local) time.
The current ranch time is
Dec 14, 2018 04:06:52.