public class FromBase extends NaryFunction
For example
jep.addFunction("fromDec",new FromBase(10)); jep.parse("fromDec(\"123.45\")"); jep.addFunction("fromHex",new FromBase(16,"0x")); jep.parse("fromHex(\"0xff\")"); jep.addFunction("fromBase",new FromBase()); jep.parse("fromBase(\"0377\",8)");
curNumberOfParameters, name, NaN, numberOfParameters
Constructor and Description |
---|
FromBase() |
FromBase(int base) |
FromBase(int base,
java.lang.String prefix) |
Modifier and Type | Method and Description |
---|---|
java.lang.Object |
eval(java.lang.Object[] args)
Evaluate the function
|
java.lang.Object |
fromBase(java.lang.String str,
int base) |
run
asArray, asBool, asDouble, asInt, asLong, asStrictInt, asString, checkNumberOfParameters, getName, getNumberOfParameters, setCurNumberOfParameters, setName, toString, toString
public FromBase()
public FromBase(int base)
public FromBase(int base, java.lang.String prefix)
public java.lang.Object eval(java.lang.Object[] args) throws EvaluationException
NaryFunction
eval
in class NaryFunction
args
- arguments to the functionEvaluationException
- if the calculation cannot be performedpublic java.lang.Object fromBase(java.lang.String str, int base) throws java.lang.NumberFormatException
java.lang.NumberFormatException
Copyright © 2018 Singular Systems http://www.singularsys.com/jep