0

I want to calculate the percent from 8000000 of 17000. The result should be 0.2125 but I'm getting always 0.0

My code

double result = 17000/8000000*100;
  • You're using int division because all your operands are int literals. – khelwood Aug 14 '20 at 18:42
  • adding .0 at the end of 17000 or 8000000 or cast one of them to double resolve the problem. `double result = 17000 / 8000000.0 * 100` – J.Adler Aug 14 '20 at 20:39

0 Answers0