All Downloads are FREE. Search and download functionalities are using the official Maven repository.

com.codetaco.algebrain.function.FuncLog Maven / Gradle / Ivy

The newest version!
package com.codetaco.algebrain.function;

import java.text.ParseException;

import com.codetaco.algebrain.Function;
import com.codetaco.algebrain.ValueStack;
import com.codetaco.algebrain.token.TokVariable;

/**
 * 

* FuncLog class. *

* * @author Chris DeGreef [email protected] * @since 1.3.9 */ public class FuncLog extends Function { /** *

* Constructor for FuncLog. *

*/ public FuncLog() { super(); } /** *

* Constructor for FuncLog. *

* * @param var a {@link com.codetaco.algebrain.token.TokVariable} object. */ public FuncLog(final TokVariable var) { super(var); } /** {@inheritDoc} */ @Override public void resolve(final ValueStack values) throws Exception { if (values.size() < 1) throw new Exception("missing operands for " + toString()); try { values.push(new Double(Math.log(values.popDouble()))); } catch (final ParseException e) { e.fillInStackTrace(); throw new Exception(toString() + "; " + e.getMessage(), e); } } /** {@inheritDoc} */ @Override public String toString() { return "function(log)"; } }




© 2015 - 2024 Weber Informatics LLC | Privacy Policy