public final void run(DoubleStack inStack) throws ParseException {
   double y = inStack.pop();
   double x = inStack.pop();
   int r;
   switch (id) {
     case 0:
       r = (x < y) ? 1 : 0;
       break;
     case 1:
       r = (x > y) ? 1 : 0;
       break;
     case 2:
       r = (x <= y) ? 1 : 0;
       break;
     case 3:
       r = (x >= y) ? 1 : 0;
       break;
     case 4:
       r = (x != y) ? 1 : 0;
       break;
     case 5:
       r = (x == y) ? 1 : 0;
       break;
     default:
       throw new ParseException("Unknown relational operator");
   }
   inStack.push(r);
 }
 public final void run(DoubleStack inStack) throws ParseException {
   double param2 = inStack.pop();
   double param1 = inStack.pop();
   double result = param1 % param2;
   inStack.push(result);
   return;
 }
 public void run(DoubleStack inStack) throws ParseException {
   if (null == inStack) {
     throw new ParseException("Stack argument null");
   }
   double r = 0;
   while (!inStack.isEmpty()) r += inStack.pop();
   inStack.push(r);
 }
    public final void run(DoubleStack inStack) throws ParseException {
      double y = inStack.pop();
      double x = inStack.pop();
      int r;

      switch (id) {
        case 0:
          // AND
          r = ((x != 0d) && (y != 0d)) ? 1 : 0;
          break;
        case 1:
          // OR
          r = ((x != 0d) || (y != 0d)) ? 1 : 0;
          break;
        default:
          r = 0;
      }

      inStack.push(r);
      return;
    }
 public final void run(DoubleStack stack) {
   stack.push(stack.pop() + stack.pop());
 }
 public final void run(DoubleStack stack) {
   stack.push(Math.abs(stack.pop()));
 }
 public void run(DoubleStack inStack) throws ParseException {
   double[] params = new double[numberOfParameters];
   for (int i = numberOfParameters - 1; i > -1; i--) params[i] = inStack.pop();
   inStack.push(operation(params));
   return;
 }
 public void run(DoubleStack inStack) throws ParseException {
   double param = inStack.pop();
   int r = (param == 0) ? 1 : 0;
   inStack.push(r);
   return;
 }
 public final void run(DoubleStack inStack) throws ParseException {
   inStack.push(inStack.pop() * inStack.pop());
   return;
 }
示例#10
0
 public final void run(DoubleStack inStack) throws ParseException {
   inStack.push(Math.random());
 }
示例#11
0
    public final void run(DoubleStack inStack) throws ParseException {
      double param2 = inStack.pop();
      double param1 = inStack.pop();

      inStack.push(Math.pow(param1, param2));
    }
示例#12
0
 public final void run(DoubleStack stack) {
   double p2 = stack.pop();
   stack.push(stack.pop() / p2);
 }
示例#13
0
 public final void run(DoubleStack stack) throws ParseException {
   stack.push(Math.sqrt(stack.pop()));
 }