Java Math floor example

Previous
Next

Java math floor function is used to get largest integer which is lesser than number.

Syntax

Example

Let’s use math’s floor function in the example.

When you run above program, output of the program will be:

Ceil value for 2.6 = 3.0
Ceil value for 26.1 = 27.0
Ceil value for -0.8 = -0.0
Ceil value for -6.2 = -6.0
Ceil value for 4.6f = 5.0

Few points about Math.ceil function:

  • In case of Nan or infinity or zero, it will give you same result as argument.
  • If you pass a value which is already equal to integer, it will result in same value.

That’s all about Java math floor function.

Previous
Next

Join Our News Letter - Stay Updated

Subscribe to Awesome Java Content.

Add Comment

Join Our News Letter - Stay Updated

Subscribe to Awesome Java Content.
You can like our facebook page Java2blog