use approximate equality with 1 ULP of tolerance

This commit is contained in:
Jorge Aparicio
2018-07-12 12:20:55 -05:00
parent 262c392cf2
commit 5b950eaea2
2 changed files with 9 additions and 3 deletions

View File

@@ -10,3 +10,9 @@ pub use fabsf::fabsf;
pub use powf::powf;
pub use scalbnf::scalbnf;
pub use sqrtf::sqrtf;
/// Approximate equality with 1 ULP of tolerance
#[doc(hidden)]
pub fn _eqf(a: u32, b: u32) -> bool {
(a as i32).wrapping_sub(b as i32).abs() <= 1
}