MathMod
MathMod
函数返回两个数字相除的余数。
double MathMod(
double value, // 股息值
double value2 // 除数值
);参量
- 值
[in] 被除数值。
- value2
[in] 除数值。
返回值
MathMod函数计算真值 f of val / y such that val = i * y + f,f是整数,f有与val相同的符号,f的绝对值小于y的绝对值。
注释
取代MathMod()可以使用 fmod()。
示例:
#property script_show_inputs
//--- 输入参数
input double InpDividentValue = 10; // 股息值
input double InpDivisorValue = 3; // 除数值
//+------------------------------------------------------------------+
//| 脚本程序起始函数 |
//+------------------------------------------------------------------+
void OnStart()
{
//--- 获取输入中输入的数字相除的实数余数
double res=MathMod(InpDividentValue,InpDivisorValue);
//--- 在日志中记录结果
PrintFormat("Real remainder when dividing %.2f by %.2f = %.2f",InpDividentValue,InpDivisorValue,res);
}