first commit
This commit is contained in:
23
hrmsEjb/org/nfunk/jep/function/Arg.java
Normal file
23
hrmsEjb/org/nfunk/jep/function/Arg.java
Normal file
@@ -0,0 +1,23 @@
|
||||
package org.nfunk.jep.function;
|
||||
|
||||
import java.util.Stack;
|
||||
import org.nfunk.jep.ParseException;
|
||||
import org.nfunk.jep.type.Complex;
|
||||
|
||||
public class Arg extends PostfixMathCommand {
|
||||
private static final Double ONE = new Double(1.0D);
|
||||
|
||||
public void run(Stack paramStack) throws ParseException {
|
||||
checkStack(paramStack);
|
||||
Object object = paramStack.pop();
|
||||
paramStack.push(arg(object));
|
||||
}
|
||||
|
||||
public Number arg(Object paramObject) throws ParseException {
|
||||
if (paramObject instanceof Complex)
|
||||
return new Double(((Complex)paramObject).arg());
|
||||
if (paramObject instanceof Number)
|
||||
return ONE;
|
||||
throw new ParseException("Invalid parameter type");
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user