Due to the way floating point numbers are represented.
If you need exact values, use BigDecimal :
BigDecimal remainder = BigDecimal.valueOf(x).remainder(BigDecimal.valueOf(y));
Another way to do this is to pluralize the values โโby 10 (or 100, 1000) other than int , and then use % .
Bozho source share