How to use the floor method in Julia

Overview

The floor(x) method will return the nearest integral value of x that is less than or equal to x.

Syntax

floor(x)

Argument

x: The value for which the floor value is to be calculated.

Return value

The nearest integral less than or equal to the specified value will be returned.

Code

The code below demonstrates how to use the floor method.

## find floor of 3
println( "floor(3) => $(floor(3))")
## find floor of 3.4
println( "floor(3.4) => $(floor(3.4))")
## find floor of 3.6
println( "floor(3.6) => $(floor(3.6))")
## find floor of 3.99
println( "floor(3.99) => $(floor(3.99))")

Explanation

In the above code, we do the following:

Line 2: We use the floor method with 3 as an argument. The floor(3) will return 3 .

Line 5: We use the floor method with 3.4 as an argument. The floor(3.4)will return 3.0.

Line 8: We use the floor method with 3.6 as an argument. The floor(3.6) will return 3.0.

Line 11: We use the floor method with 3.99 as an argument. The floor(3.99) will return 3.0.

Free Resources