Java Math.floor(double a)

Syntax

Math.floor(double a) has the following syntax.

public static double floor(double a)

Example

In the following code shows how to use Math.floor(double a) method.


/*from w  w w  .  ja v a  2 s. c  o  m*/
public class Main {

   public static void main(String[] args) {

      double x = 123456.7;
      double y = -123.45;

      // call floor and print the result
      System.out.println("Math.floor(" + x + ")=" + Math.floor(x));
      System.out.println("Math.floor(" + y + ")=" + Math.floor(y));
      System.out.println("Math.floor(0)=" + Math.floor(0));


   }
}

The code above generates the following result.





















Home »
  Java Tutorial »
    java.lang »




Boolean
Byte
Character
Class
Double
Enum
Float
Integer
Long
Math
Number
Object
Package
Process
ProcessBuilder
Runnable
Runtime
SecurityManager
Short
StackTraceElement
StrictMath
String
StringBuffer
StringBuilder
System
Thread
ThreadGroup
ThreadLocal
Throwable