Files
mql5-skills/skills/mql5/references/docs/08-math/0609-math-mathmod.md
T
2026-06-23 21:47:51 +08:00

52 lines
1.4 KiB
Markdown
Raw Blame History

This file contains invisible Unicode characters
This file contains invisible Unicode characters that are indistinguishable to humans but may be processed differently by a computer. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
# MathMod
The function returns the real remainder of division of two numbers.
```
double  MathMod(
   double  value,      // dividend value
   double  value2      // divisor value
   );
```
Parameters
value
[in]  Dividend value.
value2
[in]  Divisor value.
Return Value
The MathMod function calculates the real remainder f from expression val/y so that val = i * y + f , where i is an integer, f has the same sign as val, and the absolute value of f is less than the absolute value of y.
Note
Instead of MathMod() you can use fmod().
Example:
```
#property script_show_inputs
 
//--- input parameters
input double   InpDividentValue  =  10;   // Dividend value
input double   InpDivisorValue   =  3;    // Divisor value
 
//+------------------------------------------------------------------+
//| Script program start function                                    |
//+------------------------------------------------------------------+
void OnStart()
  {
//--- get the real remainder of the division of the numbers entered in the inputs
   double res=MathMod(InpDividentValue,InpDivisorValue);
//--- print the result in the journal
   PrintFormat("Real remainder when dividing %.2f by %.2f = %.2f",InpDividentValue,InpDivisorValue,res);
  }
```