#define VALUES_TOTAL 31
//+------------------------------------------------------------------+
//| 脚本程序起始函数 |
//+------------------------------------------------------------------+
void OnStart()
{
//--- 声明转换变量
double value=0; //用于MathFloor转换的实数
int floor_value=0; // 在这里获得结果
//--- 按实数的十进制增量数进行循环
for(int i=0; i<VALUES_TOTAL; i++)
{
//--- 增加数值,
//--- 从下面获取最接近的整数值
//--- 并在日志中显示控件值
value+=0.1;
floor_value=(int)MathFloor(NormalizeDouble(value,1));
PrintFormat("value: %.1f, floor value: %d",value,floor_value);
/*
result:
value: 0.1, floor value: 0
value: 0.2, floor value: 0
value: 0.3, floor value: 0
value: 0.4, floor value: 0
value: 0.5, floor value: 0
value: 0.6, floor value: 0
value: 0.7, floor value: 0
value: 0.8, floor value: 0
value: 0.9, floor value: 0
value: 1.0, floor value: 1
value: 1.1, floor value: 1
value: 1.2, floor value: 1
value: 1.3, floor value: 1
value: 1.4, floor value: 1
value: 1.5, floor value: 1
value: 1.6, floor value: 1
value: 1.7, floor value: 1
value: 1.8, floor value: 1
value: 1.9, floor value: 1
value: 2.0, floor value: 2
value: 2.1, floor value: 2
value: 2.2, floor value: 2
value: 2.3, floor value: 2
value: 2.4, floor value: 2
value: 2.5, floor value: 2
value: 2.6, floor value: 2
value: 2.7, floor value: 2
value: 2.8, floor value: 2
value: 2.9, floor value: 2
value: 3.0, floor value: 3
value: 3.1, floor value: 3
*/
}
|