MathRound fails for one particular number - page 2

 
Print out your values to the precision you want. Do NOT use NormalizeDouble, EVER. For ANY Reason. It's a kludge, don't use it. It's use is always wrong
 
Fernando Carreiro #:

That is not the documented way of using the MathRound() function. There is only one parameter, not two! It won't even compile that way, unless you have done something else entirely!

Documentation wrong?

https://www.mql5.com/en/docs/standardlibrary/mathematics/stat/mathsubfunctions/statmathround

Documentation on MQL5: Standard Library / Mathematics / Statistics / Subfunctions / MathRound
Documentation on MQL5: Standard Library / Mathematics / Statistics / Subfunctions / MathRound
  • www.mql5.com
MathRound(const double,const int) - Subfunctions - Statistics - Mathematics - Standard Library - MQL5 Reference - Reference on algorithmic/automated trading language for MetaTrader 5
 

You looking at a different function/method in the documentation. This is the one to which I am referring ... Documentation on MQL5: Math Functions / MathRound

I even gave you the link in my post ...

Fernando Carreiro #: That is not the documented way of using the MathRound() function. There is only one parameter, not two! It won't even compile that way, unless you have done something else entirely!
 
Fernando Carreiro #:

You looking at a different function/method in the documentation. This is the one to which I am referring ... Documentation on MQL5: Math Functions / MathRound

I even gave you the link in my post ...

Fernando Carreiro #: That is not the documented way of using the MathRound() function. There is only one parameter, not two! It won't even compile that way, unless you have done something else entirely!

Appreciated but one solution is to #include <Math\Stat\Math.mqh> and then the overrides with the decimal exists. Just a matter of wading thru the docs for various options I suppose.

 
Better use MathRound(double, digits) from my library if you seek the correct results. 


#include <math_utils.mqh>
void OnStart()
{
   double number = MathRound(0.6899999999999999,2);
   Print(number);
}

// 0.69
Math Utils
Math Utils
  • www.mql5.com
Handy functions for comparison, rounding, formatting and debugging of doubles (prices, lots and money).
Reason: