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