Skip to content

Commit

Permalink
Use abs in implementation of float_approx_eq
Browse files Browse the repository at this point in the history
  • Loading branch information
Garvys committed Oct 12, 2020
1 parent 0ba7651 commit f57c2fa
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 3 deletions.
1 change: 0 additions & 1 deletion rustfst/src/semirings/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@ mod string_weight;
mod tropical_weight;
mod union_weight;
pub(crate) mod utils_float;
pub use utils_float::float_approx_equal;

pub use self::boolean_weight::BooleanWeight;
pub use self::gallic_weight::{
Expand Down
4 changes: 2 additions & 2 deletions rustfst/src/semirings/utils_float.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
pub fn float_approx_equal(w1: f32, w2: f32, delta: f32) -> bool {
(w1 <= w2 + delta) && (w2 <= w1 + delta)
pub(crate) fn float_approx_equal(w1: f32, w2: f32, delta: f32) -> bool {
(w1 - w2).abs() <= delta
}

0 comments on commit f57c2fa

Please sign in to comment.