예제 #1
0
 public final void run(DoubleStack inStack) throws ParseException {
   double param2 = inStack.pop();
   double param1 = inStack.pop();
   double result = param1 % param2;
   inStack.push(result);
   return;
 }
예제 #2
0
 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);
 }
예제 #3
0
 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);
 }
예제 #4
0
    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;
    }
예제 #5
0
 public final void run(DoubleStack stack) {
   stack.push(stack.pop() + stack.pop());
 }
예제 #6
0
 public final void run(DoubleStack stack) {
   stack.push(Math.abs(stack.pop()));
 }
예제 #7
0
 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;
 }
예제 #8
0
 public void run(DoubleStack inStack) throws ParseException {
   double param = inStack.pop();
   int r = (param == 0) ? 1 : 0;
   inStack.push(r);
   return;
 }
예제 #9
0
 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 {
      double param2 = inStack.pop();
      double param1 = inStack.pop();

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