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

com.obdobion.algebrain.function.FuncCubeRoot Maven / Gradle / Ivy

package com.obdobion.algebrain.function;

import java.text.ParseException;

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

/**
 * @author Chris DeGreef
 *
 */
public class FuncCubeRoot extends Function
{
    public FuncCubeRoot()
    {
        super();
    }

    public FuncCubeRoot(final TokVariable var)
    {
        super(var);
    }

    @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.cbrt(values.popDouble())));
        } catch (final ParseException e)
        {
            e.fillInStackTrace();
            throw new Exception(toString() + "; " + e.getMessage(), e);
        }
    }

    @Override
    public String toString ()
    {
        return "function(cbrt)";
    }
}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy