Cutting double decimal places without rounding

 

Hi, looking for elegant way how to get next level form price, e.g. _Bid is 10888.97 and I want to elliminate 0.97 from number and get 10888.00

When I use NormalizeDouble(10888.97,0), it gets me rounded result 10889.00 and that is correct.


Converting double to string to integral and back to string and double is too heavy and there must be some better way to cut decimal places without rounding. 
//+------------------------------------------------------------------+
//| Custom indicator iteration function                              |
//+------------------------------------------------------------------+
int OnCalculate(const int rates_total,
                const int prev_calculated,
                const datetime &time[],
                const double &open[],
                const double &high[],
                const double &low[],
                const double &close[],
                const long &tick_volume[],
                const long &volume[],
                const int &spread[])
  {
//---
   double   _double  = EMPTY;
   string   _string  = "-1";
   int      _int     = EMPTY;
   
   _double = 10888.97;
   _string = DoubleToStr(_double,2);
   _int    = StrToInteger(_string);
   _string = IntegerToString(_int);
   _double = StrToDouble(_string);
   
   Print("Wanted result, "+DoubleToStr(_double,2)); // result is 10888.00
   

//--- return value of prev_calculated for next call
      return(rates_total);
  }
 

Seems I found solution to eliminate decimal places without rounding.


   _double = 10888.97;
   _double = MathFloor(_double);
   Print("wanted result, "+DoubleToStr(_double,2)); // result is 10888.00
 
Or just cast it to an int.