NormalizeDouble nn.nn9999999999 how to avoid it ???

To add comments, please log in or register
Marcin Rutkowski
129
Marcin Rutkowski  

Can some One help me how to avoid situation like this    \

where after NormalizeDouble()  we are have a digit  ended like in the title (screen shot attached)

simple example source code :


#property strict

void OnInit()
  {

   double asd;
   string qwe;
   asd=iATR(NULL,0,12,0);

   for(int i=1; i<30;i++)
     {
      asd=   iATR(NULL,0,12,i)/Point;
      asd= NormalizeDouble(asd,2);
      qwe=qwe+"\n"+(string)i+"  ATR =  "+(string)asd;
     }

   Comment((string)qwe);
   ;
  }

Thank YOu and Regards

Files:
Ex Ovo Omnia
3357
Ex Ovo Omnia  

It has nothing to do with NormalizeDouble. The last operator you used was (string). Reading the docs, you'd get:

(string) Converting double and float type variables should be as precise as possible, allowing you to only drop zeros in the fractional part.

In other part of the docs, you would read:

To convert real variables (double, float) to a string, we use the DoubleToString() function. The second parameter of this function determines the precision (the number of decimal places).

whroeder1
17949
whroeder1  
Print out your values to the precision you want. Do NOT use NormalizeDouble, EVER. For ANY Reason. It's a kludge, don't use it. It's use is always wrong
To add comments, please log in or register