Should I use MathContext.DECIMAL32
or MathContext.DECIMAL64
? I have looked at the documentation, but I couldn't really understand when to use either.
I'm using BigDecimal to represent a percentage that I want to apply to an amount of money. Something like this:
...
final MathContext mc = MathContext.DECIMAL32;
BigDecimal amount = getAmount(args);
float percent = getPercent().floatValue();
BigDecimal percentAsBd = new BigDecimal(percent/100.f, mc).setScale(4, RoundingMode.HALF_UP);
BigDecimal threshold = amount.multiply(percentAsBd);
...
I'm using oracle java 1.8, ubuntu 14.04, Intel core i7 (64bit)