Groovy - floor()



The method floor gives the largest integer that is less than or equal to the argument.

Syntax

double floor(double d) 
double floor(float f)

Parameters − A double or float primitive data type.

Return Value − This method Returns the largest integer that is less than or equal 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 a = -100.675; 
      float b = -90; 
		
      System.out.println(Math.floor(a)); 
      System.out.println(Math.floor(b)); 
   } 
}

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

-101.0 
-90.0 
groovy_numbers.htm
Advertisements