I'm going crazy!

 
double za = 100*67/750, zb = 100*142/250;
Alert(DoubleToString(za,2), "  ", DoubleToString(zb,2));

The program shows me: za = 8.00 and zb = 56.00

instead my calculator displays: za = 8.93 and zb = 56.80


Why? Why? Why? Why? Why?

 
GarZed9:

. . .

Why? Why? Why? Why? Why?

You are performing math operations on integers, and only after the operations are complete, the integer is cast to a double. See Typecasting.

Just use a double in the calculation.

Try:

double za = 100*67/750.0, zb = 100*142/250.0;
Alert(DoubleToString(za,2), "  ", DoubleToString(zb,2));

(Notice that I used 750.0 instead of 750 and 250.0 instead of 250)

 
GarZed9:
double za = 100*67/750, zb = 100*142/250;

The program shows me: za = 8.00 and zb = 56.00

On MT4 v434, division quotient don't give floating point values(Bug??) - MQL4 forum
 
Thirteen:

You are performing math operations on integers, and only after the operations are complete, the integer is cast to a double. See Typecasting.

Just use a double in the calculation.

Try:

(Notice that I used 750.0 instead of 750 and 250.0 instead of 250)



Really thanks to all!
Reason: