
please wait
|
|
double a = 7 / 2.0
;
double a = 7/2
, you gave it two integers which told the computer to use integer division which would return an integer versus the version that would return a double. To do this we could do something called type casting. In this case we would be changing either the 7 or the 2 from an int into a double. We can do this by saying:double a = 7/(double)2