Download MetaTrader 5

Arithmetic anomaly?...

To add comments, please log in or register
Do you keep a blog? Place a link to MQL5.community there and make money!
Ian Harris
106
Ian Harris 2012.01.07 01:56 

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

Slawa
Moderator
6839
Slawa 2012.01.09 12:52  

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
106
Ian Harris 2012.01.14 19:04  

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

Thanks for the clarification.

To add comments, please log in or register