This is a basic question but I can't find an answer. I've looked into floating point arithmetic and a few other topics but nothing has seemed to address this. I'm sure I just have the wrong terminology.
Basically, I want to take two quantities - completed, and total - and divide them to come up with a percentage (of how much has been completed). The quantities are
long completed = 25000;
long total = 50000;
System.out.println(completed/total); // Prints 0
Converting the output is too late; the calculation has already taken place in integer arithmetic. You need to convert the inputs to
Note that you don't actually need to convert both of them; so long as one is
double, the other will be implicitly converted. But I prefer to do both, for symmetry.