Fascinating story! This is exactly the problem that Rust’s strictness around comparing floating point numbers is designed to mitigate. Of course Rust doesn’t eliminate the danger of code like this entirely, because it’s still possible to roll your own min and max logic using < and >, but it does forbid you from naively calling min or max on floats, because floats only implement the PartialOrd trait, not Ord. Rust is the only language I know of that puts even so much as a warning label on floating point comparison.
Fascinating story! This is exactly the problem that Rust’s strictness around comparing floating point numbers is designed to mitigate. Of course Rust doesn’t eliminate the danger of code like this entirely, because it’s still possible to roll your own min and max logic using
<
and>
, but it does forbid you from naively callingmin
ormax
on floats, because floats only implement thePartialOrd
trait, notOrd
. Rust is the only language I know of that puts even so much as a warning label on floating point comparison.