mql4

Rounding in mql4


Used in mql4 language NormalizeDouble() function sometimes does not work properly. You can see in the example below.

double value=0.9731300000000001;
double value2=NormalizeDouble(value,Digits);
Print(value2);

As a result, although I want to get the result of 0.97313, the result is 0.9731300000000001. How can I fix.

double Yuvarla(double Sayi) 
{ 
    double _sayi1=MathRound(Sayi*MathPow(10,Digits)); 
    double _sayi2=_sayi1/MathPow(10,Rakam); 
    return _sayi2; 
} 

this method didn't work either


Solution

  • The data type Double saves the result correctly, but I noticed a problem when printing it to the screen. When I write to the screen as DoubleToString(data,Digits()) there is no problem