Question to the MQL4 masters. Again about Double Compare. - page 11

 

It wasn't quietly banned. But quite openly, after two warnings. This is a decent forum for serious people. Your vast knowledge is worthless if you cannot convey it in your native (hopefully not Albanianspeak) language.

 

Read it all!

Many times!

Different branches.

But I still haven't seen a summary. I would like specifics and clarity on this issue.

Gentlemen, please, if it's not a bummer, make a final conclusion (about this) -

to all, users, losers, dummies, samovars - when comparing numbers of type double we use the following:

stdlib, bool CompareDoubles(double number1,double number2);

or

if (NormalizeDouble((a-b)>0,Digits)) {...}

or

int ComparePrice(double a, double b)
{
a -= b;
b = Point / 2;
if (a > b) return (1);
if (a < -b) return (-1);
return (0);
}

or

double a;
double b;
int factor = MathRound( MathPow(10, digits) ); // digits is the accuracy to be compared
If we compare prices, this is the predefined variable Digits
...

if (MathRound( (a - b) * factor ) != 0)
{
... // a != b
}

if (MathRound( (a - b) * factor ) == 0)
{
... // a == b
}

if (MathRound( (a - b) * factor ) > 0)
{
... // a > b
}

if (MathRound( (a - b) * factor ) < 0)
{
... // a < b
}

or

When comparing double-type numbers with accuracy of up to 4-5 digits, you don't have to elaborate any more.

Regards, Alexander.