Scala Float floor() 方法与示例
floor()方法用于返回一个小于或等于给定浮点数的浮点数。
Method Definition: (Float_Number).floor
Return Type: It returns a float number which is less than or equal to the given float number.
示例 #1:
// Scala program of Float floor()
// method
// Creating object
object GfG
{
// Main method
def main(args:Array[String])
{
// Applying floor method
val result = (5.4).floor
// Displays output
println(result)
}
}
输出:
5.0
示例 #2:
// Scala program of Float floor()
// method
// Creating object
object GfG
{
// Main method
def main(args:Array[String])
{
// Applying floor method
val result = (-3.8).floor
// Displays output
println(result)
}
}
输出:
-4.0