4 ms·
> Floating point behavior Since 1.62 there have been a native way of doing it with the `total_cmp` method [0] on floating points which can be used to at least
by erk__ 4y ago
> Floating point behavior
Since 1.62 there have been a native way of doing it with the `total_cmp` method [0] on floating points which can be used to at least sort it quite easily, but cannot really use it in collections like BTreeMap.
[0]: https://doc.rust-lang.org/std/primitive.f64.html#method.total_cmp https://doc.rust-lang.org/std/primitive.f64.html#method.tota...
- spoiler 4y ago> but cannot really use it in collections like BTreeMap Given the nature of floats, is this really a problem? Worst case scenario the floats can be represented differently, if one really needs to use them as keys.
- erk__ 4y agoYeah it was mostly to give a example of where a wrapped type would be better than `total_cmp`. E.g. something that needs the value to implement Ord.