package org.nfunk.jep.function; import java.util.Stack; import org.nfunk.jep.ParseException; import org.nfunk.jep.type.Complex; public class TanH extends PostfixMathCommand { public void run(Stack paramStack) throws ParseException { checkStack(paramStack); Object object = paramStack.pop(); paramStack.push(tanh(object)); } public Object tanh(Object paramObject) throws ParseException { if (paramObject instanceof Complex) return ((Complex)paramObject).tanh(); if (paramObject instanceof Number) { double d = ((Number)paramObject).doubleValue(); return new Double((Math.exp(d) - Math.exp(-d)) / (Math.pow(Math.E, d) + Math.pow(Math.E, -d))); } throw new ParseException("Invalid parameter type"); } }