// Check if we can strip off any trailing zeros after decimal point
BigInteger i = value.unscaledValue();
int limit = value.scale();
int nshift = 0;
for (nshift = 0; nshift < limit; nshift++) {
BigInteger[] quotRem = i.divideAndRemainder(ten);
if (quotRem[REM].intValue() != 0) break;
i = quotRem[QUOT];
}
if (nshift > 0) {
value = new BigDecimal(i, limit - nshift);