need help with BigDecimal rounding

Hey, I'm trying to round a BigDecimal, but it doesn't seem to be working? I'm not sure if I'm doing it wrong or not.
BigDecimal sum = new BigDecimal("4.36");
BigDecimal coin = new BigDecimal("2.00");
BigDecimal amount = sum.divide(coin, RoundingMode.DOWN);
System.out.println(amount);
BigDecimal sum = new BigDecimal("4.36");
BigDecimal coin = new BigDecimal("2.00");
BigDecimal amount = sum.divide(coin, RoundingMode.DOWN);
System.out.println(amount);
judging by the docs https://docs.oracle.com/en/java/javase/11/docs/api/java.base/java/math/RoundingMode.html#DOWN I was expecting the amount to be 2, but instead it's 2.18
2 Replies
JavaBot
JavaBot3y ago
Hey, @Aze! Please remember to /close this post once your question has been answered!
JavaBot
JavaBot3y ago
Post Closed
This post has been closed by <@398509167351955456> for the following reason:
easiest solution was to use #intValue()
Want results from more Discord servers?
Add your server