public class Round extends NaryFunction
Note: This class was changed in version 3.4. Prior to 3.4, this class used the Math.rint method. In 3.4 and future releases Math.round will be used instead. The effect is changing the rounding behaviour when the input is equally close to two integers, Math.round rounds 1.5 down and Math.rint round it up.
RInt
,
Serialized FormcurNumberOfParameters, name, NaN, numberOfParameters
Constructor and Description |
---|
Round() |
Modifier and Type | Method and Description |
---|---|
boolean |
checkNumberOfParameters(int n)
Must have one or more parameter
|
java.lang.Object |
eval(java.lang.Object[] args)
Evaluate the function
|
protected double |
round(double val)
The rounding method which implements the core rounding operation used
in this class.
|
java.lang.Object |
round(java.lang.Object param) |
java.lang.Object |
round(java.lang.Object l,
java.lang.Object r) |
void |
run(java.util.Stack<java.lang.Object> inStack)
Creates an array of object then calls
NaryFunction.eval(Object[]) |
asArray, asBool, asDouble, asInt, asLong, asStrictInt, asString, getName, getNumberOfParameters, setCurNumberOfParameters, setName, toString, toString
public boolean checkNumberOfParameters(int n)
checkNumberOfParameters
in interface PostfixMathCommandI
checkNumberOfParameters
in class PostfixMathCommand
n
- number of parameters function will be called with.public void run(java.util.Stack<java.lang.Object> inStack) throws EvaluationException
NaryFunction
NaryFunction.eval(Object[])
run
in interface PostfixMathCommandI
run
in class NaryFunction
inStack
- arguments for functionEvaluationException
- if function cannot be evaluatedpublic java.lang.Object round(java.lang.Object l, java.lang.Object r) throws EvaluationException
EvaluationException
public java.lang.Object round(java.lang.Object param) throws EvaluationException
EvaluationException
protected double round(double val)
val
- number to roundpublic 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 performedCopyright © 2018 Singular Systems http://www.singularsys.com/jep