Groovy – rint()

  • Post author:
  • Post category:Groovy
  • Post comments:1 Comment
Rint

The method rint returns the integer that is closest in value to the argument.

Syntax

double rint(double d)

Parameters

d – it accepts a double value as parameter.

Return Value

This method Returns the integer that is closest in value to the argument. Returned as a double.

Example

Following is an example of the usage of this method −

class Example { 
   static void main(String[] args){ 
      double d = 100.675; 
      double e = 100.500; 
      double f = 100.200;
		
      System.out.println(Math.rint(d)); 
      System.out.println(Math.rint(e)); 
      System.out.println(Math.rint(f)); 
   } 
}

When we run the above program, we will get the following result −

101.0 
100.0 
100.0

Previous Page:-Click Here

This Post Has One Comment

Leave a Reply