4 ms·
As usual, Rust has a crate for that: https://crates.io/crates/float-cmp https://crates.io/crates/float-cmp
by nestorD 6y ago
As usual, Rust has a crate for that: https://crates.io/crates/float-cmp https://crates.io/crates/float-cmp
- vlovich123 6y agoThat led me to https://crates.io/crates/efloat/0.2.0 https://crates.io/crates/efloat/0.2.0 which sounds even more useful as you can actually track what the error bounds are after you've done all your math. That sounds eminently more useful than just making epsilon math correct, no?
- nsajko 6y agoThat just tracks the error bounds on individual "small" operations. I think this is more like what you want, an interval arithmetic library: https://github.com/eseraygun/rust-honestintervals https://github.com/eseraygun/rust-honestintervals The point is that AFAIK you need the whole algorithm (like, e.g., logarithm) analysed to get sensible error bounds.
- nsajko 6y agoThat does not provide an ULP distance function, rather it tests for approximate equality while using both relative and absolute error margins. Also, a warning: the code behaves as if numbers of opposite sign are never "approximately equal". Also, the documentation sucks: it doesn't even mention the sign issue, nor does it mention how NaN values are handled, but it nevertheless contains irrelevant anecdotes.