floor()
是 julia 中的一个内置函数,用于返回小于或等于指定值x的最接近的整数值。
Syntax: floor(x)
Parameters:
- x: Specified value.
Returns: It returns the nearest integral value less than or equal to the specified value x.
示例 1:
# Julia program to illustrate
# the use of floor() method
# Getting the nearest integral value
# less than or equal to the
# specified value x.
println(floor(5))
println(floor(5.9))
println(floor(5.5))
输出:
5
5.0
5.0
示例 2:
# Julia program to illustrate
# the use of floor() method
# Getting the nearest integral value
# less than or equal to the
# specified value x.
println(floor(2))
println(floor(2.1))
println(floor(2.4))
println(floor(2.5))
println(floor(2.6))
println(floor(2.9))
输出:
2
2.0
2.0
2.0
2.0
2.0