I have been trying to round using bigdecimal in java and have been running into a java.lang.ArithmeticException error that is showing Non-terminating decimal expansion.
Can anyone explain the origins of the error as I am pretty new to java? and help me with my code?
Thanks
protected BigDecimal p;
protected BigDecimal q;
protected BigDecimal d;
protected BigDecimal det;
protected BigDecimal exp;
protected int e;
this.p = pq.getP();
this.q = pq.getQ();
det = ((p.subtract(BigDecimal.ONE)).multiply(q.subtract(BigDecimal.ONE)));
exp = new BigDecimal(String.valueOf(e));
d = (det.divide(exp).setScale(2,BigDecimal.ROUND_HALF_UP));
The variable "d" is where i believe the error is arising.