Class RInt

  • All Implemented Interfaces:

    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.

    Nathan Funk
    See Also:
    Round, Serialized Form