skillerkidos1 Posted March 24, 2021 Share Posted March 24, 2021 why is this returning 0? Idk if I’m just dumb or what Quote Link to comment Share on other sites More sharing options...
Gunman Posted March 24, 2021 Share Posted March 24, 2021 3 minutes ago, skillerkidos1 said: why is this returning 0? Idk if I’m just dumb or what Isn't it because they're int and ints can't be decimals? So it defaults to int prayerPercent = 100 * 0; basically? 1 Quote Link to comment Share on other sites More sharing options...
skillerkidos1 Posted March 24, 2021 Author Share Posted March 24, 2021 33 minutes ago, Gunman said: Isn't it because they're int and ints can't be decimals? So it defaults to int prayerPercent = 100 * 0; basically? 26 minutes ago, Malcolm said: problem is when you're doing dynamic / static and you don't cast that value to a double that will return 0 due to rounding. Even if it's 0.999999 it will round down to zero. You need to cast your calculation to a double for dynamic / static and then multiply it by 100 and cast it back to an int. Example here: public int getPercentage() { double staticP = getSkills().getStatic(Skill.PRAYER); double dynamicP = getSkills().getDynamic(Skill.PRAYER); return (int) (100 * (dynamicP / staticP)); } Ohhh I see now thank you very much Quote Link to comment Share on other sites More sharing options...