MQL Math fucntion --- multiplication

 

hi guys,

i have a problem with my math multiplication.

   double inputA = 1021.00000;
   int mode = MathMod(inputA,2);
   Print(mode);//--------------------------> print result is 1, which is expected.


HOWEVER,

   double inputB = 1.02100000*1000;
   int mode = MathMod(inputB,2);
   Print(mode);//--------------------------> print result is 0, which is wrong.


Do you know what is the problem??? i need to use inputB way, since i want to substitue the "1.02100000" with variables.

 
wenfeiyunyun:

hi guys,

i have a problem with my math multiplication.

Do you know what is the problem??? i need to use inputB way, since i want to substitue the "1.02100000" with variables.

Read this thread: MQL4 - Known Issues and Best Practices

especially the page about MathMod being buggy . . . but even that proposed solution has issues, so read this: https://www.mql5.com/en/forum/143605

 

works for me now, thanks for your code.

Reason: