com.singularsys.jep.functions
Class RInt

java.lang.Object
  extended by com.singularsys.jep.functions.PostfixMathCommand
      extended by com.singularsys.jep.functions.Round
          extended by 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.

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
RInt()
           
 
Method Summary
protected  double round(double param)
          The rounding method which implements the core rounding operation used in this class.
 
Methods inherited from class com.singularsys.jep.functions.Round
checkNumberOfParameters, round, run
 
Methods inherited from class com.singularsys.jep.functions.PostfixMathCommand
asArray, asBool, asDouble, asInt, asLong, asStrictInt, asString, checkStack, getName, getNumberOfParameters, setCurNumberOfParameters, setName, toString
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

RInt

public RInt()
Method Detail

round

protected double round(double param)
Description copied from class: Round
The rounding method which implements the core rounding operation used in this class. Other subclasses (such as RInt) can override this to perform custom rounding.

Overrides:
round in class Round
Returns:
the rounded value


Copyright © 2010 Singular Systems http://www.singularsys.com/jep