WEB DEVELOPER SITE
HTMLCSSJAVASCRIPTSQLPHPBOOTSTRAPJQUERYANGULARXML
 

Java - floor() Method


Returns the largest integer that is less than or equal to the argument. Returned as a double.


Syntax

This method has the following variants −

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

Parameters

Here is the detail of 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

public class Test { 

   public static void main(String args[]) {
      double d = -200.675;
      float f = -10;

      System.out.println(Math.floor(d));
      System.out.println(Math.floor(f)); 

      System.out.println(Math.ceil(d));
      System.out.println(Math.ceil(f));
   }
}
Run example »