How to check if floating point is NaN in Scala

2 Answers

0 votes
val floatValue: Float = Float.NaN

println(floatValue.isNaN) 



/*
run:
 
true
 
*/
 

 



answered Aug 3, 2025 by avibootz
0 votes
val doubleValue: Double = Double.NaN

println(doubleValue.isNaN)



/*
run:
 
true
 
*/
 

 



answered Aug 3, 2025 by avibootz
...