A RetroSearch Logo

Home - News ( United States | United Kingdom | Italy | Germany ) - Football scores

Search Query:

Showing content from https://www.geeksforgeeks.org/java/strictmath-floor-method-in-java/ below:

StrictMath floor() Method in Java

StrictMath floor() Method in Java

Last Updated : 13 Dec, 2021

The java.lang.StrictMath.floor() is the inbuilt method which returns the largest double value, less than or equal to the given argument and is equal to the integer value. 


Syntax :  

public static double floor(double num)


Parameters: This method accepts one parameter num which is of double type .
Return Value : The method returns the largest value which, closest to positive infinity, less than or equal to the argument and equal to an integer.
Examples :  

Input: num = 9.6
Output: 9.0

Input: num = -7.8
Output: -8.0


Below programs illustrate the java.lang.StrictMath.floor() method: 
Program 1:  

java
// Java program to illustrate the
//java.lang.StrictMath.floor()

import java.lang.*;

public class Geeks {

public static void main(String[] args) {

    double num1 = 7.8, num2 = 1.4 ;

    double fValue = StrictMath.floor(num1); 
    System.out.println("The floor value of "+
                             num1+" = " + fValue);

    fValue = StrictMath.floor(num2); 
    System.out.println("The floor value of "+
                             num2+" = " + fValue);
}
}

Output: 
The floor value of 7.8 = 7.0
The floor value of 1.4 = 1.0

 

Program2: 

java
// Java program to illustrate the
//java.lang.StrictMath.floor()

import java.lang.*;

public class Geeks {

public static void main(String[] args) {

    double num1 = -7.8, num2 = -1.4 ,num3 = 0.1 ;

    double fValue = StrictMath.floor(num1); 
    System.out.println("The floor value of "+
                             num1+" = " + fValue);

    fValue = StrictMath.floor(num2); 
    System.out.println("The floor value of "+
                             num2+" = " + fValue);

    fValue = StrictMath.floor(num3); 
    System.out.println("The floor value of "+
                             num3+" = " + fValue);

}
}

Output: 
The floor value of -7.8 = -8.0
The floor value of -1.4 = -2.0
The floor value of 0.1 = 0.0

 

RetroSearch is an open source project built by @garambo | Open a GitHub Issue

Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo

HTML: 3.2 | Encoding: UTF-8 | Version: 0.7.4