SplitScript reference / Float / isNaN

Float.isNaN

Method

T.isNaN() -> bool where T: Float

Returns whether the receiver is the floating-point not-a-number value.

NaN is the only floating-point value that does not compare equal to itself.

Effects: pure

Runtime behavior: available everywhere; synchronous

Examples

Reject an invalid measurement

let measurement = "NaN".parse<f64>() else 0.0
if measurement.isNaN() {
    print("invalid measurement")
}