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.
Single argument version
rint(2.4) finds the closest integer to the argument 2 and
with two arguments
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(double) method
rather than Math.round(double). 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.1 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, description, name, NaN, numberOfParameters -
Constructor Summary
Constructors -
Method Summary
Methods inherited from class com.singularsys.jep.functions.Round
checkNumberOfParameters, eval, round, runMethods inherited from class com.singularsys.jep.functions.PostfixMathCommand
asArray, asBool, asDouble, asInt, asLong, asStrictInt, asString, asType, getDescription, getDescription, getDescriptionWithType, getName, getNumberOfParameters, setCurNumberOfParameters, setDescription, setName, toString, toString
-
Constructor Details
-
RInt
public RInt()
-
-
Method Details
-
rint
protected double rint(double param) -
round
- Overrides:
roundin classRound- Throws:
EvaluationException
-
round
- Overrides:
roundin classRound- Throws:
EvaluationException
-