#define VALUES_TOTAL 31
//+------------------------------------------------------------------+
//| Script program start function |
//+------------------------------------------------------------------+
void OnStart()
{
//--- 변환을 위한 변수 선언
double value=0; // real number for MathRound conversion
int round_value=0; // 여기서 결과를 얻습니다
//--- 실수의 소수점 증분 수만큼 루프에서
for(int i=0; i<VALUES_TOTAL; i++)
{
//--- 실수 값을 증가시키고,
//--- 가장 가까운 정수로 반올림된 숫자 값을 얻습니다.
//--- 그리고 저널에 제어 값을 표시합니다.
value+=0.1;
round_value=(int)MathRound(NormalizeDouble(value,1));
PrintFormat("value: %.1f, round value: %d",value,round_value);
/*
결과:
value: 0.1, round value: 0
value: 0.2, round value: 0
value: 0.3, round value: 0
value: 0.4, round value: 0
value: 0.5, round value: 1
value: 0.6, round value: 1
value: 0.7, round value: 1
value: 0.8, round value: 1
value: 0.9, round value: 1
value: 1.0, round value: 1
value: 1.1, round value: 1
value: 1.2, round value: 1
value: 1.3, round value: 1
value: 1.4, round value: 1
value: 1.5, round value: 2
value: 1.6, round value: 2
value: 1.7, round value: 2
value: 1.8, round value: 2
value: 1.9, round value: 2
value: 2.0, round value: 2
value: 2.1, round value: 2
value: 2.2, round value: 2
value: 2.3, round value: 2
value: 2.4, round value: 2
value: 2.5, round value: 3
value: 2.6, round value: 3
value: 2.7, round value: 3
value: 2.8, round value: 3
value: 2.9, round value: 3
value: 3.0, round value: 3
value: 3.1, round value: 3
*/
}
}
|