assert-rs / predicates-rs

Boolean-valued predicate functions in Rust
docs.rs/predicates
Apache License 2.0
176 stars 29 forks source link

Floating point "closeness" predicate #11

Closed epage closed 6 years ago

epage commented 6 years ago

This isn't needed for any of my cases but just wanted to bring it up for rounding things out.

Floating point equality is weird. Generally, its best to do a "closeness" check.

epage commented 6 years ago

Hamcrest seems to have this https://github.com/ujh/hamcrest-rust/blob/master/src/matchers/close_to.rs

epage commented 6 years ago

float_cmp might be useful for this https://mikedilger.github.io/float-cmp/float_cmp/index.html

See also