@Test public void givenPositiveValueAndZeroExponentWhenRaisingValueByExponentThenResultIsOne() throws SetlException { Rational number = Rational.EIGHT; Rational exponent = Rational.ZERO; Value result = number.power(state, exponent); assertEquals(Rational.ONE, result); }
@Override protected Rational power(final State state, final int exponent) throws UndefinedOperationException { if (exponent >= 0) { return new Rational(numerator.pow(exponent), denominator.pow(exponent )); } else if (ZERO.equals(this)) { throw new UndefinedOperationException("'0 ** " + exponent + "' is undefined."); } return new Rational(denominator.pow(exponent * -1), numerator.pow(exponent * -1)); }
Rational extends NumberValue { @Override protected Rational power(final State state, final int exponent) throws UndefinedOperationException { if (exponent >= 0) { return new Rational(numerator.pow(exponent), denominator.pow(exponent )); } else if (ZERO.equals(this)) { throw new UndefinedOperationException("'0 ** " + exponent + "' is undefined."); } return new Rational(denominator.pow(exponent * -1), numerator.pow(exponent * -1)); } }
Rational extends NumberValue { @Override protected Rational power(final State state, final int exponent) throws UndefinedOperationException { if (exponent >= 0) { return new Rational(numerator.pow(exponent), denominator.pow(exponent )); } else if (ZERO.equals(this)) { throw new UndefinedOperationException("'0 ** " + exponent + "' is undefined."); } return new Rational(denominator.pow(exponent * -1), numerator.pow(exponent * -1)); } private  Rational(final long number); private  Rational(final BigInteger number); private  Rational(BigInteger n, BigInteger d); }
Rational extends NumberValue { @Override protected Rational power(final State state, final int exponent) throws UndefinedOperationException { if (exponent >= 0) { return new Rational(numerator.pow(exponent), denominator.pow(exponent )); } else if (ZERO.equals(this)) { throw new UndefinedOperationException("'0 ** " + exponent + "' is undefined."); } return new Rational(denominator.pow(exponent * -1), numerator.pow(exponent * -1)); } private  Rational(final long number); private  Rational(final BigInteger number); private  Rational(BigInteger n, BigInteger d); static Rational valueOf(final long number); static Rational valueOf(final String string); static Rational valueOf(final BigInteger number); static Rational valueOf(final BigInteger numerator, final BigInteger denominator); static Rational valueOf(final long numerator, final long denominator); @Override Rational clone(); boolean isPrime(); boolean isProbablePrime(); Rational nextProbablePrime(final State state); @Override SetlBoolean isInteger(); @Override SetlBoolean isRational(); @Override Rational toInteger(final State state); @Override Rational toRational(); @Override SetlDouble toDouble(); @Override boolean jIntConvertible(); @Override boolean jDoubleConvertible(); @Override double toJDoubleValue(final State state); @Override int jIntValue(); @Override Rational absoluteValue(final State state); @Override Rational ceil(final State state); @Override Value difference(final State state, final Value subtrahend); @Override Rational factorial(final State state); @Override void fillCollectionWithinRange(final State state,
                                          final Value step,
                                          final Value stop,
                                          final CollectionValue collection); @Override Rational floor(final State state); @Override Value integerDivision(final State state, final Value divisor); @Override Rational minus(final State state); @Override Value modulo(final State state, final Value modulus); @Override Value product(final State state, final Value multiplier); @Override Value quotient(final State state, final Value divisor); @Override Rational rnd(final State state); @Override Rational rnd(final State state, final Value numberOfChoices); @Override Rational round(final State state); @Override Value sum(final State state, final Value summand); @Override void appendString(final State state, final StringBuilder sb, final int tabs); @Override SetlString charConvert(final State state); @Override int compareTo(final CodeFragment other); @Override int numericalComparisonTo(final NumberValue other); @Override final long compareToOrdering(); @Override boolean equals(final Object other); @Override int computeHashCode(); }
Rational extends NumberValue { @Override protected Rational power(final State state, final int exponent) throws UndefinedOperationException { if (exponent >= 0) { return new Rational(numerator.pow(exponent), denominator.pow(exponent )); } else if (ZERO.equals(this)) { throw new UndefinedOperationException("'0 ** " + exponent + "' is undefined."); } return new Rational(denominator.pow(exponent * -1), numerator.pow(exponent * -1)); } private  Rational(final long number); private  Rational(final BigInteger number); private  Rational(BigInteger n, BigInteger d); static Rational valueOf(final long number); static Rational valueOf(final String string); static Rational valueOf(final BigInteger number); static Rational valueOf(final BigInteger numerator, final BigInteger denominator); static Rational valueOf(final long numerator, final long denominator); @Override Rational clone(); boolean isPrime(); boolean isProbablePrime(); Rational nextProbablePrime(final State state); @Override SetlBoolean isInteger(); @Override SetlBoolean isRational(); @Override Rational toInteger(final State state); @Override Rational toRational(); @Override SetlDouble toDouble(); @Override boolean jIntConvertible(); @Override boolean jDoubleConvertible(); @Override double toJDoubleValue(final State state); @Override int jIntValue(); @Override Rational absoluteValue(final State state); @Override Rational ceil(final State state); @Override Value difference(final State state, final Value subtrahend); @Override Rational factorial(final State state); @Override void fillCollectionWithinRange(final State state,
                                          final Value step,
                                          final Value stop,
                                          final CollectionValue collection); @Override Rational floor(final State state); @Override Value integerDivision(final State state, final Value divisor); @Override Rational minus(final State state); @Override Value modulo(final State state, final Value modulus); @Override Value product(final State state, final Value multiplier); @Override Value quotient(final State state, final Value divisor); @Override Rational rnd(final State state); @Override Rational rnd(final State state, final Value numberOfChoices); @Override Rational round(final State state); @Override Value sum(final State state, final Value summand); @Override void appendString(final State state, final StringBuilder sb, final int tabs); @Override SetlString charConvert(final State state); @Override int compareTo(final CodeFragment other); @Override int numericalComparisonTo(final NumberValue other); @Override final long compareToOrdering(); @Override boolean equals(final Object other); @Override int computeHashCode(); final static Rational ZERO; final static Rational ONE; final static Rational TWO; final static Rational THREE; final static Rational FOUR; final static Rational FIVE; final static Rational SIX; final static Rational SEVEN; final static Rational EIGHT; final static Rational NINE; final static Rational TEN; }