When evaluating order of operations like a problem x = a + (b - c) / (d - e * f). Do you evaluate left to right or right to left? Thanks for your time guys.
-Will
When evaluating order of operations like a problem x = a + (b - c) / (d - e * f). Do you evaluate left to right or right to left? Thanks for your time guys.
-Will
as far as I know it is always left to right for all infix notation
It's actually not defined, believe it or not!Originally posted by samps005
as far as I know it is always left to right for all infix notation
Only a few operators guarantee order, which include
||
&&
so that you can be certain of the short-circut evaluation.
with addition, subtraction, etc. it's up to the compiler to choose order.
so in
a + (b - c) / (d - e * f).
The compiler can do
b - c
first, or it can do
( d - e * f )
first. It's not defined by the standard.
I think you confused him... anyway it is on page 200 of the The C Programming Lang book (K & R).
Mr. C: Author and Instructor