I have the following variables:
int first = 0;
int end = 0;
Declare in the public class.
Within a method:
double diff = end / first;
double finaldiff = 1 - diff;
The end variable on System.out.println is 527, the first is 480.
Why is the answer for diff coming out as 1? It should be 1.097916667, I thought using a double would enable me to calculate into decimals?
Dividing two
ints will get you anint, which is then implicitly converted todouble. Cast one to adoublebefore the divison: