Change a Long Array to Double Array

 

Dear


How can I change a Long Array[] to a Double Array[]? 


Thanks

Victor

 

doublevalue = (double)longvalue;

use this casting code for each value by loop

 
Thanks! Now works!
 
template<typename T1, typename T2>
int cast_array(T1 &cast_this[], T2 &to_this[])
{ 
   int total = ArrayResize(to_this, ArraySize(cast_this));
   for(int i=0; i<total; i++)
      to_this[i] = (T2)cast_this[i];
   return total;
}

void OnStart()
{
   int int_arr[] = {1,2,3,4};
   double dbl_arr[];
   int total = cast_array(int_arr, dbl_arr);
   for(int i=0; i<total; i++) {
      printf("<type=%s> %.2f", typename(dbl_arr[i]), dbl_arr[i]);
   }
}

 
nicholi shen:

You are a funny guy. The OP doesn't even know the basic of coding (regarding his question) and you come with template. For sure he will understand all.
 
OP doesn't need to know how it works, just how to use it. I'm sure you don't know how most of the MQL functions are implemented behind the scenes, but I'd bet that you know how to use each and every one. 
 
nicholi shen:
OP doesn't need to know how it works, just how to use it. I'm sure you don't know how most of the MQL functions are implemented behind the scenes, but I'd bet that you know how to use each and every one. 

Yes and the point is, most probably, he will not be able to use it. Mql functions are documented.

Anyway, I know I am preaching in desert.