rint method

DD rint()

Rounds this value to the nearest integer. The value is rounded to an integer by adding 1/2 and taking the floor of the result. Special cases:

  • If this value is NaN, returns NaN.

@return this value rounded to the nearest integer

Implementation

DD rint() {
  if (isNaN()) return this;
// may not be 100% correct
  DD plus5 = this.add(0.5);
  return plus5.floor();
}