Download MetaTrader 5

StringFormat correct behaviour?

To add comments, please log in or register
Track all payments in your profile. It is easy!
Mihai Ionescu
1300
Mihai Ionescu 2011.07.13 15:12 

I saw StringFormat doesn't print correctly a double as an int. 

For example:

printf(StringFormat("int1=%i, int2=%d, double=%f",0.00356,0.00356*10000,0.00356));

and it yields:

int1=1918647790, int2=-858993459, double=0.003560

 

 

is this correct or is it a bug

Get in touch with developers using Service Desk!
  • www.mql5.com
We therefore attach great importance to all user reports about issues in our programs and try to answer each one of them.
Ilyas
1205
Ilyas 2011.07.13 15:21  

Try this code

printf(StringFormat("int1=%i, int2=%d, double=%f",0.00356,(int)(0.00356*10000),0.00356));
In future compiler will check parameters with format (first parameter of StringFormat function)
Mihai Ionescu
1300
Mihai Ionescu 2011.07.13 16:06  
mql5:

Try this code

In future compiler will check parameters with format (first parameter of StringFormat function)

Thank you.

It came to me I should cast it myself to be sure.

To add comments, please log in or register