Skip to content

Round down a number using floor method of Java Math class

Java Math floor method example shows how to round down a number using the floor method of the Java Math class.

How to round down a number using the floor method of Math class?

We can use the floor method of Java Math class to round down a number.

This method returns the largest double number which is equal to or less than the argument and is equal to an integer.

Output

Please note that -5.01 and -5.99 return -6 because -6 is the smallest integer less than both of them.

Please, also not that the floor method returns a double. You may need to cast it to an appropriate data type from the double value.

This example is a part of the Java Math class tutorial with examples.

Please let me know your views in the comments section below.

About the author

Leave a Reply

Your email address will not be published.