I want to get two ints, one divided by the other to get a decimal or percentage. How can I get a percentage or decimal of these two ints? (I\'m not sure if it is right.. I\'
Two options:
Do the division after the multiplication:
int n = 25; int v = 100; int percent = n * 100 / v;
Convert an int to a float before dividing
int
float
int n = 25; int v = 100; float percent = n * 100f / v; //Or: // float percent = (float) n * 100 / v; // float percent = n * 100 / (float) v;