forked from rosh/MQL5Book
22 lines
1,020 B
MQL5
22 lines
1,020 B
MQL5
//+------------------------------------------------------------------+
| |||
//| MathMod.mq5 |
| |||
//| Copyright 2021, MetaQuotes Ltd. |
| |||
//| https://www.mql5.com |
| |||
//+------------------------------------------------------------------+
| |||
| |||
#define PRT(A) Print(#A, "=", (A))
| |||
| |||
//+------------------------------------------------------------------+
| |||
//| Script program start function |
| |||
//+------------------------------------------------------------------+
| |||
void OnStart()
| |||
{
| |||
// 10.0 % 3.0; // '%' - illegal operation use
| |||
PRT(MathMod(10.0, 3)); // 1.0
| |||
PRT(MathMod(10.0, 3.5)); // 3.0
| |||
PRT(MathMod(10.0, 3.49)); // 3.02
| |||
PRT(MathMod(10.0, M_PI)); // 0.5752220392306207
| |||
PRT(MathMod(10.0, -1.5)); // 1.0, sign is gone
| |||
PRT(MathMod(-10.0, -1.5)); // -1.0
| |||
}
| |||
//+------------------------------------------------------------------+
|