Exemplo n.º 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);
 }
Exemplo n.º 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;
 }
Exemplo n.º 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);
 }
Exemplo n.º 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;
    }
Exemplo n.º 5
0
 public final void run(DoubleStack stack) {
   stack.push(stack.pop() + stack.pop());
 }
Exemplo n.º 6
0
 public final void run(DoubleStack stack) {
   stack.push(Math.abs(stack.pop()));
 }
Exemplo n.º 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;
 }
Exemplo n.º 8
0
 public void run(DoubleStack inStack) throws ParseException {
   double param = inStack.pop();
   int r = (param == 0) ? 1 : 0;
   inStack.push(r);
   return;
 }
Exemplo n.º 9
0
 public final void run(DoubleStack inStack) throws ParseException {
   inStack.push(inStack.pop() * inStack.pop());
   return;
 }
Exemplo n.º 10
0
 public final void run(DoubleStack inStack) throws ParseException {
   inStack.push(Math.random());
 }
Exemplo n.º 11
0
    public final void run(DoubleStack inStack) throws ParseException {
      double param2 = inStack.pop();
      double param1 = inStack.pop();

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