How to change int to double? - page 2

 
@Peter Williams #: Fernando - another simple example of  a simple EA & it's output

Your post does not have a question. What is it that you wish to know?

In your examples, both "c1 = a1 / b1" and "c2 = a2 / b2", carry out integer division. Even if the results are assigned to a "double", they are still the results of integer division.

If that is not want you want or expect, then apply typecasting as shown in my examples so that it will carry out floating point division.

double   c1 = (double) a1 / b1;
double   c2 = (double) a2 / b2;
 
Fernando Carreiro #:

Your post does not have a question. What is it that you wish to know?

In your examples, both "c1 = a1 / b1" and "c2 = a2 / b2", carry out integer division. Even if the results are assigned to a "double", they are still the results of integer division.

If that is not want you want or expect, then apply typecasting as shown in my examples so that it will carry out floating point division.

Apologies for the confusion I was just adding examples which I thought maybe a useful illustration - no question
 
Fernando Carreiro #:

As I stated, learn about typecasting — Typecasting - Data Types - Language Basics - MQL4 Reference.

Don't use string manipulation. That is incorrect and inefficient.

... or more simply, you can rely on implicit typecasting ...

... or inline typecasting ...

Wow, thanks! I didn't think of this solution. I am new to programming.
Reason: