Package com.singularsys.jep.functions
Class RInt
- java.lang.Object
-
- com.singularsys.jep.functions.PostfixMathCommand
-
- com.singularsys.jep.functions.NaryFunction
-
- com.singularsys.jep.functions.Round
-
- com.singularsys.jep.functions.RInt
-
- All Implemented Interfaces:
PostfixMathCommandI
,java.io.Serializable
public class RInt extends Round
A PostfixMathCommandI which rounds a number to the closest integer.
rint(2.4) finds the closest integer to the argument (2).
rint(2.1234, 3) rounds the argument to 3 decimal places (2.123).RInt differs from the Round class in that it uses the Math.rint() method rather than Math.round(). Unlike Math.round(), in the case of a tie (e.g 1.5) Math.rint() prefers the nearest even integer (so rint(1.5) = 2). This has better statistical properties. For the two argument version you can consider it as a rounding method with a mode of round-half-even.
- Since:
- 3.4
- Author:
- Nathan Funk
- See Also:
Round
, Serialized Form
-
-
Field Summary
-
Fields inherited from class com.singularsys.jep.functions.PostfixMathCommand
curNumberOfParameters, name, NaN, numberOfParameters
-
-
Constructor Summary
Constructors Constructor Description RInt()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description protected double
rint(double param)
java.lang.Object
round(java.lang.Object arg)
java.lang.Object
round(java.lang.Object l, java.lang.Object r)
-
Methods inherited from class com.singularsys.jep.functions.Round
checkNumberOfParameters, eval, round, run
-
Methods inherited from class com.singularsys.jep.functions.PostfixMathCommand
asArray, asBool, asDouble, asInt, asLong, asStrictInt, asString, getName, getNumberOfParameters, setCurNumberOfParameters, setName, toString, toString
-
-
-
-
Method Detail
-
rint
protected double rint(double param)
-
round
public java.lang.Object round(java.lang.Object arg) throws EvaluationException
- Overrides:
round
in classRound
- Throws:
EvaluationException
-
round
public java.lang.Object round(java.lang.Object l, java.lang.Object r) throws EvaluationException
- Overrides:
round
in classRound
- Throws:
EvaluationException
-
-