コード例 #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()));
 }