im trying to calculate some value but the result is infinity :
double a;
a=1/3;
result=1/(a);
Log.e("Result a : ", String.valueOf(result));
Result Log
Result a : Infinity
why the result infinity? im try this code on excel and the result is 3, anyone can solved this problem?
ANSWER from Good Luck Thanks 1/3 error because its integer, just change to be 1.0/3.0 and Problem Solved
when you have a=1/3, a becomes zero because it is the division of two integer numbers. If you want to get the double result (i.e. 0.3333), you should change the code to a=1.0/3.0.