Answers for "NaN check in swift"

1

check if nan swift

let x = 0.0
let y = x * .infinity
// y is a NaN

// Comparing with the equal-to operator never returns 'true'
print(x == Double.nan)
// Prints "false"
print(y == Double.nan)
// Prints "false"

// Test with the 'isNaN' property instead
print(x.isNaN)
// Prints "false"
print(y.isNaN)
// Prints "true"
Posted by: Guest on June-11-2020

Code answers related to "Swift"

Browse Popular Code Answers by Language