Files
HRMS/hrmsEjb/org/nfunk/jep/function/Logical.java
2025-07-28 13:56:49 +05:30

43 lines
1.1 KiB
Java

package org.nfunk.jep.function;
import java.util.Stack;
import org.nfunk.jep.ParseException;
public class Logical extends PostfixMathCommand {
int id;
public static final int AND = 0;
public static final int OR = 1;
public Logical(int paramInt) {
this.id = paramInt;
this.numberOfParameters = 2;
}
public void run(Stack paramStack) throws ParseException {
checkStack(paramStack);
Number number1 = (Number)paramStack.pop();
Number number2 = (Number)paramStack.pop();
if (number2 instanceof Number && number1 instanceof Number) {
boolean bool;
double d1 = ((Number)number2).doubleValue();
double d2 = ((Number)number1).doubleValue();
switch (this.id) {
case 0:
bool = (d1 != 0.0D && d2 != 0.0D) ? true : false;
break;
case 1:
bool = (d1 != 0.0D || d2 != 0.0D) ? true : false;
break;
default:
bool = false;
break;
}
paramStack.push(new Double(bool));
} else {
throw new ParseException("Invalid parameter type");
}
}
}