Scala Float isNaN() 方法与示例
如果此浮点值或指定的浮点值是非数字 (NaN),则使用isNaN()方法返回 true,否则返回 false。
Method Definition: (Float_Number).isNaN
Return Type: It returns true if this Float value or the specified float value is Not-a-Number (NaN), or false otherwise.
示例 #1:
// Scala program of Float isNaN()
// method
// Creating object
object GfG
{
// Main method
def main(args:Array[String])
{
// Applying isNaN method
val result = (0.0/0.0).isNaN
// Displays output
println(result)
}
}
输出:
true
示例 #2:
// Scala program of Float isNaN()
// method
// Creating object
object GfG
{
// Main method
def main(args:Array[String])
{
// Applying isNaN method
val result = (5.7).isNaN
// Displays output
println(result)
}
}
输出:
false