Download MetaTrader 5

Is that bug?

To add comments, please log in or register
Any questions regarding MQL5 Cloud Network? FAQ will help you!
ngoc thach
53
ngoc thach 2013.12.21 05:32 
int start()
  {
   int    counted_bars=IndicatorCounted();
   
//----
   double factor;
   int x1=60,x2=125;
   factor=x1/x2;
   //factor=0.12345;
   Comment(x1,"/",x2,"= ",DoubleToStr(factor,4));
//----
   return(0);
  }
//+------------------------------------------------------------------+

I have a simply code.

when put on the chart, it give me wrong result.


Why?

When i test with 0.12345, its work!

//factor=0.12345;
ngoc thach
53
ngoc thach 2013.12.21 05:41  

Ok

Now i know :D

Examples:

int    i = 1 / 2;     // no types casting, the result is 0
int    i = 1 / 2.0;   // the expression is cast to the double type, then is to the target type of int, the result is 0
double d = 1.0 / 2.0; // no types casting, the result is 0.5
double d = 1 / 2.0;   // the expression is cast to the double type that is the same as the target type, the result is 0.5
double d = 1 / 2;     // the expression of the int type is cast to the target type of double, the result is 0.0
string s = 1.0 / 8;   // the expression is cast to the double type, then is to the target type of string, the result is "0.12500000" (the string containing 10 characters)
string s = NULL;      // the constant of type int is cast to the target type of string, the result is "0" (the string containing 1 character)
string s = "Ticket #"+12345; // the expression is cast to the string type that is the same as the target type, the result is "Ticket #12
To add comments, please log in or register