public Number divideImpl(Number left, Number right) { return BigDecimalMath.INSTANCE.divideImpl(left, right); }
protected Number unaryPlusImpl(Number left) { return toBigDecimal(left); } }
public Number divideImpl(Number left, Number right) { //Hack until Java 1.5 BigDecimal is available. For now, pick //a result scale which is the maximum of the scale of the //two operands and an arbitrary maximum (similar to what a //handheld calculator would do). Then, normalize the result //by removing any trailing zeros. BigDecimal bigLeft = toBigDecimal(left); BigDecimal bigRight = toBigDecimal(right); int scale = Math.max(bigLeft.scale(), bigRight.scale()); return normalize(bigLeft.divide(bigRight, Math.max(scale, MAX_DIVISION_SCALE), BigDecimal.ROUND_HALF_UP)); }
protected Number divideImpl(Number left, Number right) { //Hack until Java 1.5 BigDecimal is available. For now, pick //a result scale which is the maximum of the scale of the //two operands and an arbitrary maximum (similar to what a //handheld calculator would do). Then, normalize the result //by removing any trailing zeros. BigDecimal bigLeft = toBigDecimal(left); BigDecimal bigRight = toBigDecimal(right); int scale = Math.max(bigLeft.scale(), bigRight.scale()); return normalize(bigLeft.divide(bigRight, Math.max(scale, MAX_DIVISION_SCALE), BigDecimal.ROUND_HALF_UP)); }
public Number addImpl(Number left, Number right) { return toBigDecimal(left).add(toBigDecimal(right)); }
public Number divideImpl(Number left, Number right) { return BigDecimalMath.INSTANCE.divideImpl(left, right); }
public Number divideImpl(Number left, Number right) { //Hack until Java 1.5 BigDecimal is available. For now, pick //a result scale which is the maximum of the scale of the //two operands and an arbitrary maximum (similar to what a //handheld calculator would do). Then, normalize the result //by removing any trailing zeros. BigDecimal bigLeft = toBigDecimal(left); BigDecimal bigRight = toBigDecimal(right); int scale = Math.max(bigLeft.scale(), bigRight.scale()); return normalize(bigLeft.divide(bigRight, Math.max(scale, MAX_DIVISION_SCALE), BigDecimal.ROUND_HALF_UP)); }
public Number multiplyImpl(Number left, Number right) { return toBigDecimal(left).multiply(toBigDecimal(right)); }
public Number divideImpl(Number left, Number right) { return BigDecimalMath.INSTANCE.divideImpl(left, right); }
public int compareToImpl(Number left, Number right) { return toBigDecimal(left).compareTo(toBigDecimal(right)); }
public Number divideImpl(Number left, Number right) { return BigDecimalMath.INSTANCE.divideImpl(left, right); }
public Number subtractImpl(Number left, Number right) { return toBigDecimal(left).subtract(toBigDecimal(right)); }
public Number divideImpl(Number left, Number right) { return BigDecimalMath.INSTANCE.divideImpl(left, right); }
protected Number absImpl(Number number) { return toBigDecimal(number).abs(); }
public Number divideImpl(Number left, Number right) { return BigDecimalMath.INSTANCE.divideImpl(left, right); }
protected Number unaryMinusImpl(Number left) { return toBigDecimal(left).negate(); }
protected Number divideImpl(Number left, Number right) { return BigDecimalMath.INSTANCE.divideImpl(left, right); }
public Number divideImpl(Number left, Number right) { BigDecimal bigLeft = toBigDecimal(left); BigDecimal bigRight = toBigDecimal(right); try { return bigLeft.divide(bigRight); } catch (ArithmeticException e) { // set a DEFAULT precision if otherwise non-terminating int precision = Math.max(bigLeft.precision(), bigRight.precision()) + DIVISION_EXTRA_PRECISION; BigDecimal result = bigLeft.divide(bigRight, new MathContext(precision)); int scale = Math.max(Math.max(bigLeft.scale(), bigRight.scale()), DIVISION_MIN_SCALE); if (result.scale() > scale) result = result.setScale(scale, BigDecimal.ROUND_HALF_UP); return result; } }
public Number divideImpl(Number left, Number right) { return BigDecimalMath.INSTANCE.divideImpl(left, right); }
protected int compareToImpl(Number left, Number right) { return toBigDecimal(left).compareTo(toBigDecimal(right)); }