Пример #1
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);
 }
Пример #2
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;
 }
Пример #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 {
   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()));
 }