This week's book giveaway is in the OO, Patterns, UML and Refactoring forum. We're giving away four copies of Refactoring for Software Design Smells: Managing Technical Debt and have Girish Suryanarayana, Ganesh Samarthyam & Tushar Sharma on-line! See this thread for details.
Hi Vineela, 1.) every call to the m method is evaluated, this results in: m( 1 + 2 % 3 * 4 ) 2.) the expression is evaluated from left to right and following the precendence rules which looks like this with brackets: m1(1 + ((2 % 3) * 4)) and results in: m1(9) the whole thing gives us: 1,2,3,4,9, HTH, greetings, Gian Franco
"Eppur si muove!"
Joined: Dec 20, 2003
Hi Gian, But A/c to Operator Precedence '*' is having highest precedence than '%'.So, i think the exp should be evaluated as 1+(2%(3*4)) resulting in a value of 3. Am i going wrong anywhere? Pls correct me. Regards Vineela
Joined: Dec 16, 2003
Hi Vineela, the operators * and % have the same precedence and it depends on which one comes first when read from left to right. So the following: m(m(1) + m(4) * m(2) % m(3));
gives another result than m(m(1) + m(2) % m(3) * m(4));