I have a test of division, where I sometimes need to check that my results are either NaN
or inf
, but it seems like Rust does not consider NaN to be equal to NaN:
fn main() {
let nan = "NaN".parse::<f64>().unwrap();
println!("{:?}", nan);
println!("{:?}", nan == nan);
} // NaN false
How do I compare two vectors that contain NaN and infinity to see whether they are equal?