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