Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

There's a helpful crate that abstracts that away: https://docs.rs/ordered-float/latest/ordered_float/

You have a strongly ordered `NotNan` struct that wraps a float that's guaranteed to not be NaN, and an `OrderedFloat` that consideres all NaN equal, and greater than non-NaN values.

These are basically the special-cases you'd need to handle yourself anyway, and probably one of the approaches you'd end up taking.



Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: