first commit

This commit is contained in:
2025-07-28 13:56:49 +05:30
commit e9eb805edb
3438 changed files with 520990 additions and 0 deletions

View File

@@ -0,0 +1,30 @@
package org.nfunk.jep.function;
import java.util.Stack;
import org.nfunk.jep.ParseException;
import org.nfunk.jep.type.Complex;
public class Logarithm extends PostfixMathCommand {
private static final double LOG10 = Math.log(10.0D);
private static final Complex CLOG10 = new Complex(Math.log(10.0D), 0.0D);
public void run(Stack paramStack) throws ParseException {
checkStack(paramStack);
Object object = paramStack.pop();
paramStack.push(log(object));
}
public Object log(Object paramObject) throws ParseException {
if (paramObject instanceof Complex)
return ((Complex)paramObject).log().div(CLOG10);
if (paramObject instanceof Number) {
double d = ((Number)paramObject).doubleValue();
if (d > 0.0D)
return new Double(Math.log(d) / LOG10);
Complex complex = new Complex(d);
return complex.log().div(CLOG10);
}
throw new ParseException("Invalid parameter type");
}
}