@Test(expectedExceptions = {ArithmeticException.class}) public void testNonViableDivCauseZero() { BtrpNumber i = new BtrpNumber(5, BtrpNumber.Base.BASE_16); i.div(new BtrpNumber(0, BtrpNumber.Base.BASE_16)); }
@Override public BtrpNumber div(BtrpOperand other) { checkType(other); BtrpNumber x = (BtrpNumber) other; if (Double.doubleToRawLongBits(x.dVal) == 0) { throw new ArithmeticException("Division by 0"); } double res = dVal / x.dVal; return isInteger && x.isInteger ? new BtrpNumber((int) res, base) : new BtrpNumber(res); }
BtrpNumber extends DefaultBtrpOperand { @Override public BtrpNumber div(BtrpOperand other) { checkType(other); BtrpNumber x = (BtrpNumber) other; if (Double.doubleToRawLongBits(x.dVal) == 0) { throw new ArithmeticException("Division by 0"); } double res = dVal / x.dVal; return isInteger && x.isInteger ? new BtrpNumber((int) res, base) : new BtrpNumber(res); } }
BtrpNumber extends DefaultBtrpOperand { @Override public BtrpNumber div(BtrpOperand other) { checkType(other); BtrpNumber x = (BtrpNumber) other; if (Double.doubleToRawLongBits(x.dVal) == 0) { throw new ArithmeticException("Division by 0"); } double res = dVal / x.dVal; return isInteger && x.isInteger ? new BtrpNumber((int) res, base) : new BtrpNumber(res); } BtrpNumber(int v, Base b);  BtrpNumber(double d); }
BtrpNumber extends DefaultBtrpOperand { @Override public BtrpNumber div(BtrpOperand other) { checkType(other); BtrpNumber x = (BtrpNumber) other; if (Double.doubleToRawLongBits(x.dVal) == 0) { throw new ArithmeticException("Division by 0"); } double res = dVal / x.dVal; return isInteger && x.isInteger ? new BtrpNumber((int) res, base) : new BtrpNumber(res); } BtrpNumber(int v, Base b);  BtrpNumber(double d); @Override Type type(); Base getBase(); @Override BtrpNumber power(BtrpOperand nb); @Override BtrpNumber plus(BtrpOperand other); @Override BtrpNumber minus(BtrpOperand other); @Override BtrpNumber negate(); @Override BtrpNumber times(BtrpOperand other); @Override BtrpNumber div(BtrpOperand other); @Override BtrpNumber remainder(BtrpOperand other); @Override boolean equals(Object o); @Override int hashCode(); @Override String toString(); @Override int degree(); int getIntValue(); double getDoubleValue(); @Override BtrpNumber eq(BtrpOperand other); @Override BtrpNumber geq(BtrpOperand other); @Override BtrpNumber gt(BtrpOperand other); @Override BtrpNumber not(); @Override BtrpNumber copy(); boolean isInteger(); }
BtrpNumber extends DefaultBtrpOperand { @Override public BtrpNumber div(BtrpOperand other) { checkType(other); BtrpNumber x = (BtrpNumber) other; if (Double.doubleToRawLongBits(x.dVal) == 0) { throw new ArithmeticException("Division by 0"); } double res = dVal / x.dVal; return isInteger && x.isInteger ? new BtrpNumber((int) res, base) : new BtrpNumber(res); } BtrpNumber(int v, Base b);  BtrpNumber(double d); @Override Type type(); Base getBase(); @Override BtrpNumber power(BtrpOperand nb); @Override BtrpNumber plus(BtrpOperand other); @Override BtrpNumber minus(BtrpOperand other); @Override BtrpNumber negate(); @Override BtrpNumber times(BtrpOperand other); @Override BtrpNumber div(BtrpOperand other); @Override BtrpNumber remainder(BtrpOperand other); @Override boolean equals(Object o); @Override int hashCode(); @Override String toString(); @Override int degree(); int getIntValue(); double getDoubleValue(); @Override BtrpNumber eq(BtrpOperand other); @Override BtrpNumber geq(BtrpOperand other); @Override BtrpNumber gt(BtrpOperand other); @Override BtrpNumber not(); @Override BtrpNumber copy(); boolean isInteger(); static final BtrpNumber TRUE; static final BtrpNumber FALSE; }