Q:

Math -not getting result when less than 1

I have a math problem. actually it is a really simple one, but for some reason I can't get a simple math action to show inside a TextView.
I want to show the user knowledge so I entered values from calculation into a double. Then tried getting it into a TextView by using Double.toString..
the code is
double knoledgePercentage = ((100/(endingPoint - startingPoint))*knownCount);
    tv.setText(Double.toString(knoledgePercentage));

the thing is that I even tried doing the math with number, to see that the variables is ok. id did like this:
double knoledgePercentage = ((100/400)*3);
    tv.setText(Double.toString(knoledgePercentage));

and still it shows 0.0 in the TextView.
just to be clear my problem is not with using the TextView but with doing the math.

A:

You are using integer division in Java, which truncates any decimal, because an int divided by an int must still yield an int.  So, 100/400 is 0 in Java, not 0.25.  Only then is it assigned to a double and promoted to a double, 0.0.
Cast one of the literals into a double or use double literals to force floating-point math.
double knoledgePercentage = (((double) 100/400)*3);

or
double knoledgePercentage = ((100.0/400)*3);

