MathMod curiosity

 

I'm essentially trying to produce this code:

NormalizeDouble(MathMod(0.073,0.0365),_Digits);

but actually using variables as such:

double m_mod = 0.0;
double m_value1 = 0.0;
double m_value2 = 0.0;

m_value2 = 0.073;
m_value2 = 0.0365

m_mod = NormalizeDouble(MathMod(m_value1, m_value2), _Digits);

The results from the first code are correct (0.0) but I'm getting m_mod to equal 0.037 from the second form which is obviously wrong.

I thought it could be type conversion issue but couldn't see anything wrong. Any ideas what I'm doing wrong to get the invalid value.

Thanks in advance.

 
  1. m_value2 = 0.073;
    m_value2 = 0.0365
    Floating-point has infinite number of decimals, it's your not understanding floating-point and that some numbers can't be represented exactly. (like 1/10.)
              Double-precision floating-point format - Wikipedia, the free encyclopedia

    See also The == operand. - MQL4 programming forum

  2. Problems with MathMod/fmod
              Checking for Price multiples of 20 points to Pyramid trade - Best EA - MQL4 programming forum

Reason: