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

> 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.tota...



> 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.


Yeah 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.




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

Search: