MathFloor

The function returns integer numeric value closest from below.

double  MathFloor(
   double  val     // number
   );

Parameters

val

[in]  Numeric value.

Return Value

A numeric value representing the largest integer that is less than or equal to val.

Note

Instead of MathFloor() you can use floor().

 

Example:

#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=0i<VALUES_TOTALi++)
     {
      //--- 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:
      value0.1floor value0
      value0.2floor value0
      value0.3floor value0
      value0.4floor value0
      value0.5floor value0
      value0.6floor value0
      value0.7floor value0
      value0.8floor value0
      value0.9floor value0
      value1.0floor value1
      value1.1floor value1
      value1.2floor value1
      value1.3floor value1
      value1.4floor value1
      value1.5floor value1
      value1.6floor value1
      value1.7floor value1
      value1.8floor value1
      value1.9floor value1
      value2.0floor value2
      value2.1floor value2
      value2.2floor value2
      value2.3floor value2
      value2.4floor value2
      value2.5floor value2
      value2.6floor value2
      value2.7floor value2
      value2.8floor value2
      value2.9floor value2
      value3.0floor value3
      value3.1floor value3
      */
     }