[BUG] Convert double to long

 

MT5 build 2009.

Just try following code:

void OnStart() {
  string real_number = "4.467916942e9";

  //double d_amount = StringToDouble(real_number);
  double d_amount = 4.467916942e9;
  ulong l_amount = (ulong)d_amount;
  printf("amount: %s, %f, %u", real_number, d_amount, l_amount);

  d_amount = StringToDouble("3.1415926");
  l_amount = long(d_amount);
  printf("amount: %s, %f, %u", "3.1415926", d_amount, l_amount);
}

Always get wrong reslut:


 
  printf("amount: %s, %f, %llu", real_number, d_amount, l_amount);
 
Alain Verleyen:

Got it. Thx