package org.nfunk.jep.function;

import java.util.Stack;
import org.nfunk.jep.ParseException;
import org.nfunk.jep.type.Complex;

public class Real extends PostfixMathCommand {
  public void run(Stack paramStack) throws ParseException {
    checkStack(paramStack);
    Object object = paramStack.pop();
    paramStack.push(re(object));
  }
  
  public Number re(Object paramObject) throws ParseException {
    if (paramObject instanceof Complex)
      return new Double(((Complex)paramObject).re()); 
    if (paramObject instanceof Number)
      return (Number)paramObject; 
    throw new ParseException("Invalid parameter type");
  }
}
