Order of evaluation of operator with same precedence
1 posts in topic
Flat View  Flat View
TOPIC ACTIONS:
 

Posted By:   Manivannan_E
Posted On:   Monday, March 29, 2004 01:36 AM

Hi,

I would like to know how to change the evaluation
order in an expression with operator having same
precedence. For example: a/b*c it can be evaluated
from right to left or left to right. So for both the
cases the result are different.

In my case, it evaluated from right to left, I want it
to evaluate from left to right. How will I do it?


-- mani

Re: Order of evaluation of operator with same precedence

Posted By:   Tim_Frith  
Posted On:   Wednesday, March 31, 2004 11:13 PM

I think the simplest way is just to add parenthesis to the expression to explicitly specify order of evaluation:

(a / b) * c

or
a /(b * c)


Personally, I like to always use lots of parenthesis so it is always clear what the intent is of the expression.

Hope this helps...
About | Sitemap | Contact