Download MetaTrader 5

Division double wrong

To add comments, please log in or register
No time to learn MQL5? The source code library is at your service!
Suibo Wen
4518
Suibo Wen 2014.02.28 14:32 

Hi, why code below output zero which is wrong?

double b=0;
b=30/100;
printf(b); //output zero wrong


and code below output is correct.

double b=0;

b=30.0/100.0;

printf(b); //output 0.3 correctly


Thanks.

Alain Verleyen
Moderator
30707
Alain Verleyen 2014.02.28 19:00  
Suibo Wen
4518
Suibo Wen 2014.03.01 11:55  
Thank you.
To add comments, please log in or register