#define VALUES_TOTAL 31
//+------------------------------------------------------------------+
//| Script program start function |
//+------------------------------------------------------------------+
void OnStart()
{
//--- declare variables for conversion
double value=0; // real number for MathFloor conversion
int floor_value=0; // get the result here
//--- in a loop by the number of decimal increments of a real number
for(int i=0; i<VALUES_TOTAL; i++)
{
//--- increase the number value,
//--- get the nearest integer value from below
//--- and display control values in the journal
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
*/
}
|