i am trying to do some calculations in Java, but for some reason a simple calculation in 1 or 2 lines of code gives me the wrong answer, while on the other hand if i do it in 3 steps it works flawlessly.
i know that's it not that bad to do something in a couple more steps, but why use extra text if it can be shortened??
Could someone give me a pointer if my math is wrong??
this is the 1 line code
percent1 = (((totaloutput1Int - Total1Int) / totaloutput1Int) * 100);
also = (((2232 - 1590) / 2232) * 100)
and this is the multiple steps code which does work.
percent1step1 = (totaloutput1Int - Total1Int);
percent1step2 = ((percent1step1 / totaloutput1Int)* 100);
percent1Tv.setText(String.valueOf(percent1step2));