/** * Evaluates the arithmetic comparison on its two numeric arguments. * * @param firstNumber The first argument. * @param secondNumber The second argument. * * @return The result of performing the arithmetic comparison on its arguments. */ protected boolean evaluate(NumericType firstNumber, NumericType secondNumber) { // If either of the arguments is a real number, then use real number arithmetic, otherwise use integer arithmetic. if (firstNumber.isInteger() && secondNumber.isInteger()) { return firstNumber.intValue() > secondNumber.intValue(); } else { return firstNumber.doubleValue() > secondNumber.doubleValue(); } } }
/** * Evaluates the arithmetic comparison on its two numeric arguments. * * @param firstNumber The first argument. * @param secondNumber The second argument. * * @return The result of performing the arithmetic comparison on its arguments. */ protected boolean evaluate(NumericType firstNumber, NumericType secondNumber) { // If either of the arguments is a real number, then use real number arithmetic, otherwise use integer arithmetic. if (firstNumber.isInteger() && secondNumber.isInteger()) { return firstNumber.intValue() >= secondNumber.intValue(); } else { return firstNumber.doubleValue() >= secondNumber.doubleValue(); } } }
/** * Evaluates the arithmetic comparison on its two numeric arguments. * * @param firstNumber The first argument. * @param secondNumber The second argument. * * @return The result of performing the arithmetic comparison on its arguments. */ protected boolean evaluate(NumericType firstNumber, NumericType secondNumber) { // If either of the arguments is a real number, then use real number arithmetic, otherwise use integer arithmetic. if (firstNumber.isInteger() && secondNumber.isInteger()) { return firstNumber.intValue() <= secondNumber.intValue(); } else { return firstNumber.doubleValue() <= secondNumber.doubleValue(); } } }
/** * Evaluates the arithmetic comparison on its two numeric arguments. * * @param firstNumber The first argument. * @param secondNumber The second argument. * * @return The result of performing the arithmetic comparison on its arguments. */ protected boolean evaluate(NumericType firstNumber, NumericType secondNumber) { // If either of the arguments is a real number, then use real number arithmetic, otherwise use integer arithmetic. if (firstNumber.isInteger() && secondNumber.isInteger()) { return firstNumber.intValue() < secondNumber.intValue(); } else { return firstNumber.doubleValue() < secondNumber.doubleValue(); } } }
/** * Evaluates the arithmetic operator on its two numeric arguments. * * @param firstNumber The first argument. * @param secondNumber The second argument. * * @return The result of performing the arithmetic operator on its arguments. */ protected NumericType evaluate(NumericType firstNumber, NumericType secondNumber) { // If either of the arguments is a real number, then use real number arithmetic, otherwise use integer arithmetic. if (firstNumber.isInteger() && secondNumber.isInteger()) { return new IntLiteral(firstNumber.intValue() - secondNumber.intValue()); } else { return new DoubleLiteral(firstNumber.doubleValue() - secondNumber.doubleValue()); } } }
/** * Evaluates the arithmetic operator on its two numeric arguments. * * @param firstNumber The first argument. * @param secondNumber The second argument. * * @return The result of performing the arithmetic operator on its arguments. */ protected NumericType evaluate(NumericType firstNumber, NumericType secondNumber) { // If either of the arguments is a real number, then use real number arithmetic, otherwise use integer arithmetic. if (firstNumber.isInteger() && secondNumber.isInteger()) { return new IntLiteral(firstNumber.intValue() * secondNumber.intValue()); } else { return new DoubleLiteral(firstNumber.doubleValue() * secondNumber.doubleValue()); } } }
/** * Evaluates the arithmetic operator on its two numeric arguments. * * @param firstNumber The first argument. * @param secondNumber The second argument. * * @return The result of performing the arithmetic operator on its arguments. */ protected NumericType evaluate(NumericType firstNumber, NumericType secondNumber) { // If either of the arguments is a real number, then use real number arithmetic, otherwise use integer arithmetic. if (firstNumber.isInteger() && secondNumber.isInteger()) { return new IntLiteral(firstNumber.intValue() / secondNumber.intValue()); } else { return new DoubleLiteral(firstNumber.doubleValue() / secondNumber.doubleValue()); } } }
/** * Evaluates the arithmetic operator on its two numeric arguments. * * @param firstNumber The first argument. * @param secondNumber The second argument. * * @return The result of performing the arithmetic operator on its arguments. */ protected NumericType evaluate(NumericType firstNumber, NumericType secondNumber) { // If either of the arguments is a real number, then use real number arithmetic, otherwise use integer arithmetic. if (firstNumber.isInteger() && secondNumber.isInteger()) { return new IntLiteral(firstNumber.intValue() + secondNumber.intValue()); } else { return new DoubleLiteral(firstNumber.doubleValue() + secondNumber.doubleValue()); } } }
/** * Evaluates the arithmetic operator on its numeric argument. * * @param firstNumber The first argument. * * @return The result of performing the arithmetic operator on its argument. */ protected NumericType evaluate(NumericType firstNumber) { // If the argument is a real number, then use real number arithmetic, otherwise use integer arithmetic. if (firstNumber.isInteger()) { return new IntLiteral(-firstNumber.intValue()); } else { return new DoubleLiteral(-firstNumber.doubleValue()); } } }
/** {@inheritDoc} */ public boolean proofStep(ResolutionState state) { Functor goalTerm = state.getGoalStack().poll().getFunctor(); Term argument = goalTerm.getArgument(0).getValue(); // Check that the argument is not a free variable. return argument.isNumber() && ((NumericType) argument.getValue()).isInteger(); } }