Use
double number = getNom() / (double)getDenom();
how to make a method return a double [duplicate]
-
03-10-2022 - |
سؤال
i have the following code and getNom and getdenom are both integers for example 2 and 5. How come I am getting the output of 0.0 here and not 0.4? Thank you.
public double divide() {
double number = getNom() / getDenom();
rn.toString(number);
return number;
المحلول
نصائح أخرى
One alternative is use double number = getNom() * 1.0 / getDenom();
لا تنتمي إلى StackOverflow