带有示例的 Scala Float isWhole() 方法
isWhole()方法用于如果指定的数字没有任何小数部分,则返回 true,否则返回 false。
Method Definition: (Float_Number).isWhole
Return Type: It returns true if the specified number is not having any decimal component, otherwise it returns false.
示例 #1:
// Scala program of Float isWhole()
// method
// Creating object
object GfG
{
// Main method
def main(args:Array[String])
{
// Applying isWhole method
val result = (5).isWhole
// Displays output
println(result)
}
}
输出:
true
示例 #2:
// Scala program of Float isWhole()
// method
// Creating object
object GfG
{
// Main method
def main(args:Array[String])
{
// Applying isWhole method
val result = (5.9).isWhole
// Displays output
println(result)
}
}
输出:
false