For my project I have decided to store money as an Integer (pence) instead of using BigDecimal and Co.
But I'm having some trouble with percentage calculation and two decimal rounding.
for example I wish to calculate the 2.9% of 11.88$ which would be:
1188 * 0.029 = 34.452 = 35 (so 0.35$)
(the .4 round to .5 so the 34 round 35)
But cannot manage to arrive to this result using Math.round or Math.ceil.
double r = Math.round(34.452)
r = 34
is there a way in Java using double/long to round as in my example ?
(Note: using BigDecimal and setScale(2, RoundingMode.CEILING) is works perfectly)
1.03356 1.03356