Find floor value of a number using Math.floor - Java Language Basics

Java examples for Language Basics:Math

Introduction

To find a floor value, use static double floor(double d) method of Math class.

It returns a largest integer which is not greater than the argument value.

Demo Code


public class Main {
 
  public static void main(String[] args) {
    System.out.println(Math.floor(110));
   //from w w  w.j  a va 2 s. c om
    System.out.println(Math.floor(310.1));
   
    System.out.println(Math.floor(115.5));
   
    System.out.println(Math.floor(-41));
   
    System.out.println(Math.floor(-421.4));
   
    System.out.println(Math.floor(0));
   
  }
}

Result


Related Tutorials