The usual mathematical definition of Modulo operations is usually only with Integers.
Some languages such as C# allow for the use of floating point calculations, however, assuming that MQL is built upon a Unix C foundation, it is most probably only valid for integers.
Unfortunately, the MQL documentation is not very clear on this point, plus it is misspelled as "Module" instead of "Modulo" or "Modulus".
The usual mathematical definition of Modulo operations is usually only with Integers.
Some languages such as C# allow for the use of floating point calculations, however, assuming that MQL is built upon a Unix C foundation, it is most probably only valid for integers.
Unfortunately, the MQL documentation is not very clear on this point, plus it is misspelled as "Module" instead of "Modulo" or "Modulus".
Thanks FMIC,
I just wanted to make sure that it wasn't a bug.
I can easily sort out what I want to do with MathFloor, I think.
Up until now, I guess that I have only used integers when using % in my code.
works fine
Compiler reports error '%' - illegal operation use
as does
Compiler seems very clear though. Only integers.
"illegal operation use" wasn't very clear to me :(
I don't see anywhere that it says only integers
"illegal operation use" wasn't very clear to me :(
I don't see anywhere that it says only integers
Have you tested MathMod() ? does it still have the same issues it had before ? https://www.mql5.com/en/forum/143605
Thanks Raptor, I didn't even know about MathMod(), I will look into it.
I was thinking along the lines of
double a = 1.5; double b = 3.1; double c = MathFloor(b/a); double remainder = b-c*a; Alert(remainder);
But of course that returns
0.100000000000001
Thanks Raptor, I didn't even know about MathMod(), I will look into it.
I was thinking along the lines of
But of course that returns
0.100000000000001
You can use a variation of the below function (showed in https://www.mql5.com/en/articles/1561).
//+------------------------------------------------------------------+ //| correct comparison of 2 doubles | //+------------------------------------------------------------------+ bool CompareDoubles(double number1,double number2) { if(NormalizeDouble(number1-number2,8)==0) return(true); else return(false); }

- www.mql5.com
Why are you replying to a topic that is over 4 years old?

- Free trading apps
- Over 8,000 signals for copying
- Economic news for exploring financial markets
You agree to website policy and terms of use
Up until now, I guess that I have only used integers when using % in my code.
works fine
Compiler reports error '%' - illegal operation use
as does