@Test(expectedExceptions = {UnsupportedOperationException.class}) public void testNonViablePower() { BtrpNumber i = new BtrpNumber(5, BtrpNumber.Base.BASE_16); Model mo = new DefaultModel(); BtrpElement j = new BtrpElement(BtrpOperand.Type.VM, "foo", mo.newVM()); i.power(j); }
@Override public BtrpNumber power(BtrpOperand nb) { checkType(nb); BtrpNumber x = (BtrpNumber) nb; if (x.dVal <= 0) { throw new UnsupportedOperationException(nb + " must be strictly positive"); } double res = Math.pow(dVal, x.dVal); return isInteger && x.isInteger ? new BtrpNumber((int) res, base) : new BtrpNumber(res); }
BtrpNumber extends DefaultBtrpOperand { @Override public BtrpNumber power(BtrpOperand nb) { checkType(nb); BtrpNumber x = (BtrpNumber) nb; if (x.dVal <= 0) { throw new UnsupportedOperationException(nb + " must be strictly positive"); } double res = Math.pow(dVal, x.dVal); return isInteger && x.isInteger ? new BtrpNumber((int) res, base) : new BtrpNumber(res); } }
BtrpNumber extends DefaultBtrpOperand { @Override public BtrpNumber power(BtrpOperand nb) { checkType(nb); BtrpNumber x = (BtrpNumber) nb; if (x.dVal <= 0) { throw new UnsupportedOperationException(nb + " must be strictly positive"); } double res = Math.pow(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 power(BtrpOperand nb) { checkType(nb); BtrpNumber x = (BtrpNumber) nb; if (x.dVal <= 0) { throw new UnsupportedOperationException(nb + " must be strictly positive"); } double res = Math.pow(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 power(BtrpOperand nb) { checkType(nb); BtrpNumber x = (BtrpNumber) nb; if (x.dVal <= 0) { throw new UnsupportedOperationException(nb + " must be strictly positive"); } double res = Math.pow(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; }