From Double to Int. How to remove the warning : possible loss of data due to type conversion.

 

Hello,

How to remove the warning :

possible loss of data due to type conversion FromDoubleToInt.mq4 20 9

   //+------------------------------------------------------------------+
   //|                                              FromDoubleToInt.mq4 |
   //|                                         Copyright 2014, Pierre8r |
   //|                                              https://www.mql4.com |
   //+------------------------------------------------------------------+
   #property copyright "Copyright 2014, Pierre8r"
   #property link      "https://www.mql4.com"
   #property version   "1.00"
   #property strict
   //+------------------------------------------------------------------+
   //| Script program start function                                    |
   //+------------------------------------------------------------------+
   void OnStart()
     {
   //---
   
      double doubleFrom=2;
      int intTo;
   
      intTo=doubleFrom;
     }
   //+------------------------------------------------------------------+
 
intTo=(int)doubleFrom;

But i would not recommend you to do it

this is a reminder (warning) that if you have a decimal number, you will lose it during the conversion from double to int

 

Thanks qjol.

But i would not recommend you to do it

Yes, but I get a Double and I need a Integer.

And I don't like warning.

void CParallels::formatLine(string lineName,color lineColor)
  {
   double bufferNumber=GlobalVariableGet("gvCounterBufferNumber");
   bufferNumber++;
   GlobalVariableSet("gvCounterBufferNumber",bufferNumber);
   Print("gvCounterBufferNumber : ",DoubleToString(bufferNumber));

   string  bufferName=lineName+DoubleToString(bufferNumber);
   addLine(new CLine((int)bufferNumber,bufferName,lineColor));
  }
//+------------------------------------------------------------------+
 

Don't use a GV if you dont want a double. Save to file instead.

Reason: