1 9 package org.nfunk.jep.function; 10 11 import java.lang.Math ; 12 import java.util.*; 13 import org.nfunk.jep.*; 14 import org.nfunk.jep.type.*; 15 16 21 public class ArcCosine extends PostfixMathCommand 22 { 23 public ArcCosine() 24 { 25 numberOfParameters = 1; 26 27 } 28 29 public void run(Stack inStack) 30 throws ParseException 31 { 32 checkStack(inStack); Object param = inStack.pop(); 34 inStack.push(acos(param)); return; 36 } 37 38 public Object acos(Object param) 39 throws ParseException 40 { 41 if (param instanceof Complex) 42 { 43 return ((Complex)param).acos(); 44 } 45 else if (param instanceof Number ) 46 { 47 return new Double (Math.acos(((Number )param).doubleValue())); 48 } 49 50 throw new ParseException("Invalid parameter type"); 51 } 52 53 } 54 | Popular Tags |