Features of the mql5 language, subtleties and tricks - page 241
You are missing trading opportunities:
- Free trading apps
- Over 8,000 signals for copying
- Economic news for exploring financial markets
Registration
Log in
You agree to website policy and terms of use
If you do not have an account, please register
As long as the two amounts are equal, any one of them is a valid minimum. Consider MathMin(1, 1), it does not differ if the function returns the first (1) or second (1).
So, returning 0.0 is not different from -0.0.
Edit: by the way, the two highlighted expressions are NOT identical.I think I agree with my colleague amrali. I would also add that there is a native function MathMin(). It also thinks that zeros with different signs are equal. As far as I understand, its algorithm is quite simple. I duplicated it in my CustomMathMin() function.
We have it in the log:
It is easy to see that from two equal numbers, the algorithm will take the second number as the minimum value of...
You refuse to understand.
it's nothing special. Just -0.0==0.0.
nothing special. Just -0.0==0.0
I know the question very well, so I wrote both variants of MathMin to show that mathematically identical functions in programming languages produce different results.
I have an excellent understanding of the question, so I wrote both versions of MathMin to show that mathematically identical functions in programming languages produce different results.
So what is unusual?
The fact that in the numbers 0.0 and -0.0 not all 64 bits are the same is obvious:
but still 0.0 == -0.0
The < and <= signs seem to be different.....
agree
So what is unusual?
The fact that in the numbers 0.0 and -0.0 not all 64 bits are the same is obvious:
It expects MathMin() to be deterministic. So to always give the same result when the two arguments are the same. And not a different result depending on which argument is first or second.
fxsaber is right, this is a problem.
It expects the MathMin() function to be deterministic. So to always give the same result when the two arguments are the same. And not a different result depending on which argument is first or second....
And it is. When 2 numbers are equal, the second one is returned. I have shown above with an example...
and there's nothing wrong with that.
It expects the MathMin() function to be deterministic. So to always give the same result when the two arguments are the same. And not a different result depending on which argument is first or second.
fxsaber is right, this is a problem.
You've got my point right. You can run into the hard-to-find issue of getting different results in large code. That's why I notified the community in this thread.
It expects the MathMin() function to be deterministic. So to always give the same result when the two arguments are the same. And not a different result depending on which argument is first or second.
fxsaber is right, this is a problem.
ahhh..., then why was it so confusing about " Mathematically the same expression (highlighted) " and union
was enough:
but since 0.0 == -0.0, then I can't imagine a situation where this could be a problem and, affect anything at all