Originally posted by Jayashree Mohan:
See this...
int i = 4*6-3/2<<2*5>>>1%2-4^3;
According to me, arithmetic operations preceed over binary shift operators , taking this into account, the answer to i is 0 but when I run , I get an answer 3.
This is how I evaluated.
int i = ((4*6)-(3/2))<<2*5>>>((1%2)-(4^3))
int i = 23<<10>>>-2
int i = 23552>>>-2
int i = 0
Now, what is wrong ???
Of cource ,it's wrong .
PRI : Unary > Arithmetic > Relational > Logical > Conditional > Assignment.
*/+-<<>>> are Arithmetic ,and ^ is Logical .
SO:
int i = 24-1<<10>>>2-4^3
i = 23<<10>>2-4^3
i = 23<<10>>-2^3
i = 0^3
I hope it can help you.
Leoo yu