public class Log2Function extends java.lang.Object implements JepExpressionFunction
log2(expression)
function to a
JEP expression parser. The function will look take the 2-based logarithm of
it's argument.
This function is added automatically by the Jep.newJep(String, JepFunction[])
method to the parser.
Jep
Modifier and Type | Field and Description |
---|---|
private static double |
LOG2
The natural logarithm of 2.
|
private static Log2Function |
theInstance
The one and only instance of this function.
|
Modifier | Constructor and Description |
---|---|
private |
Log2Function()
Create a new instance of this function.
|
Modifier and Type | Method and Description |
---|---|
boolean |
checkNumberOfParameters(int n) |
java.lang.String |
getFunctionName()
Get the name of this function.
|
static Log2Function |
getInstance()
Get the singleton instance of this function.
|
int |
getNumberOfParameters() |
double |
log2(java.lang.Number argument)
Calculate the 2-based logarithm of the argument.
|
void |
run(java.util.Stack stack) |
void |
setCurNumberOfParameters(int n) |
Expression |
toExpression(Node node)
Use the
Expressions.log2(Expression) method to create an
expression taking the 2-based logarithm of the argument. |
private static final Log2Function theInstance
private static final double LOG2
ln(x) / ln(2)
public static Log2Function getInstance()
public java.lang.String getFunctionName()
JepFunction
JEP
parser.getFunctionName
in interface JepFunction
JEP.addFunction(String, PostfixMathCommandI)
public Expression toExpression(Node node)
Expressions.log2(Expression)
method to create an
expression taking the 2-based logarithm of the argument.toExpression
in interface JepExpressionFunction
node
- The node representing this functionExpression
objectpublic int getNumberOfParameters()
getNumberOfParameters
in interface org.nfunk.jep.function.PostfixMathCommandI
public void setCurNumberOfParameters(int n)
setCurNumberOfParameters
in interface org.nfunk.jep.function.PostfixMathCommandI
public boolean checkNumberOfParameters(int n)
checkNumberOfParameters
in interface org.nfunk.jep.function.PostfixMathCommandI
public void run(java.util.Stack stack) throws ParseException
run
in interface org.nfunk.jep.function.PostfixMathCommandI
ParseException
public double log2(java.lang.Number argument) throws ParseException
argument
- A number to calculate onParseException
- If the logarithm could not be calculated.