Download MetaTrader 5

Arithmetic anomaly?...

To add comments, please log in or register
Ian Harris
107
Ian Harris  

All,

Not sure about this one. I learned in school that it doestn' matter what order additions and subtractions are done, the result is always the same. But look at the screenshot. Notice that the result for mrequest.sl is different to sl9. The only difference between the expresseions is the mrequest.sl has brackets inserted around the MathMax expression. This generates the correct result. sl9 is incorrect. Am I missing something obvious??? Thanks, Ian

Math anomaly

Slava
Moderator
7089
Slava  

mogplus8:

The only difference between the expresseions is the mrequest.sl has brackets inserted around the MathMax expression. This generates the correct result. sl9 is incorrect. Am I missing something obvious???


1. Expressions in brackets have more priority than without.

2. Operations of adding and subrtracting have the same priority and processed from left to right

compare please:

2 - 1 + 1 = 2

2 - (1 + 1) = 0 surprise!

Ian Harris
107
Ian Harris  

Maybe I need to go back to primary maths class.   :-( 

Thanks for the clarification.

To add comments, please log in or register