Double.isNaN
property in Swift is used to check if an instance of type double is NaN
(Not a Number).
Double.isNaN
This function does not take any parameters.
The value returned is a boolean value.
// create some valueslet d1 = 1.2let d2 = 0.0let d3 = Double.infinity * 0.0let d4 = Double.infinitylet d5 = Double.nan * 2// check if Not a Numberprint(d1.isNaN) // falseprint(d2.isNaN) // falseprint(d3.isNaN) // trueprint(d4.isNaN) // falseprint(d5.isNaN) // true
NaN
and print the results to the console.