Java – Math floor() Example, Math floor Program

Math class is part of java.lang package. Math floor method returns the lower nearest value of double number in fraction. If value is negative, it will return nearest to lowest value. floor function return type is double.

Math floor example explains how to use Math floor function in java.

public class JavaMathFloorExample {

    public static void main(String[] args) {

        double E1 = Math.floor(14.2345);

        double E2 = Math.floor(14.5345);

        double E3 = Math.floor(-14.2345);

        double E4 = Math.floor(-14.5345);

        System.out.println("Math floor value :"+E1);
        System.out.println("Math floor value :"+E2);
        System.out.println("Math floor value :"+E3);
        System.out.println("Math floor value :"+E4);
    }
}

Output

Math floor value :14.0
Math floor value :14.0
Math floor value :-15.0
Math floor value :-15.0

Tags:

Bookmark  

 

Leave a Reply

Security Code:

 

  Random Post