package org.nfunk.jep.function;

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

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