Download MetaTrader 5
To add comments, please log in or register
Write your articles using our editor. It is convenient!
Pierre Rougier
386
Pierre Rougier 2014.05.14 12:10 

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;
     }
   //+------------------------------------------------------------------+
qjol
3243
qjol 2014.05.14 12:27  
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

Pierre Rougier
386
Pierre Rougier 2014.05.14 13:11  

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));
  }
//+------------------------------------------------------------------+
Ian Venner
2583
Ian Venner 2014.05.14 17:49  

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

/
To add comments, please log in or register