std-method
Floating-point is_nan
Identify undefined floating-point results before using them as ordinary measurements. Expected stdout (not executed): true false Common mistake: Comparing a number to NAN with == cannot detect NaN.
Formal Syntax & Structure
rust syntaxrust
x.is_nan() -> boolWorking Example
Example Snippetrust
fn main() { let reading = (-1.0_f64).sqrt(); println!("{}", reading.is_nan()); println!("{}", reading == reading);}