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
,Serializable
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(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.
In Jep 4.2 fixes a bug with round(100000,-5) -> 99999.99999999999
.
- Since:
- 3.4
- Author:
- Nathan Funk
- See Also:
-
Field Summary
Fields inherited from class com.singularsys.jep.functions.PostfixMathCommand
curNumberOfParameters, name, NaN, numberOfParameters
-
Constructor Summary
-
Method Summary
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
-
Constructor Details
-
RInt
public RInt()
-
-
Method Details
-
rint
protected double rint(double param) -
round
- Overrides:
round
in classRound
- Throws:
EvaluationException
-
round
- Overrides:
round
in classRound
- Throws:
EvaluationException
-