Problem with doc

Hi,
In doc it is written here

NaN is considered equal to itself

but I tried this

import kotlin.math.*
var x = sqrt(-1.0)
println(x)
println(x == x)

result is

NaN
false

I don’t understand doc

You missed the clause before:

when the operands are not statically typed as floating point numbers (e.g. Any , Comparable<...> , a type parameter),

import kotlin.math.*
fun main() {
   val x = kotlin.math.sqrt(-1.0)
   println(x)
   println(x == x)
   val y: Any = x
   println(y)
   println(y == y)  
}
1 Like