What is the evaluation order in C in the case x<<y>>z? Is (x<<y)>>zit due to associativity from left to right?
x<<y>>z
(x<<y)>>z
EDIT You need to know that the standards report this, and not know what happens when checking for a particular compiler.
Online Project C 2011 (N1570)
6.5.7 Bitwise shift operators Syntax 1 shift-expression: additive-expression shift-expression << additive-expression shift-expression >> additive-expression
The syntax indicates that both operators are left-associative, as shown below:
x << y >> z | | | | +------ + ------+ | | | | | V | V shift-expression >> additive-expression
, >> << , x << y >> z (x << y) >> z.
>>
<<
x << y >> z
(x << y) >> z
, , < → -.
<< >> , .
.. http://msdn.microsoft.com/en-us/library/2bxt6kc4%28v=vs.71%29.aspx
Yes, but I think it is safer to do this in 2 steps, for example x<<y, and then y>>zmake the compiler misinterpret a x<<y>>z. I have not used bitwise operations since all the time, but if I remember well what I said. I hope I helped you.
x<<y
y>>z