Rounding down a float or a double

Use the floor method in the Math class. It rounds down to the next lower integer:

import java.math.*;
                           
public class Main 
{  
   public static void main(String args[]) throws Exception {
      double d1 = 1.3, 
             d2 = 1.8,
             d3 = -1.3, 
             d4 = -1.8;
 
      System.out.println(Math.floor(d1));
      System.out.println(Math.floor(d2));
      System.out.println(Math.floor(d3));
      System.out.println(Math.floor(d4));
   }
}

outputs:

1.0
1.0
-2.0
-2.0