Move binned type, add tests
This commit is contained in:
@@ -14,6 +14,20 @@ use bytes::BytesMut;
|
||||
use err::Error;
|
||||
use std::future::Future;
|
||||
|
||||
fn f32_cmp_near(x: f32, y: f32) -> bool {
|
||||
let x = {
|
||||
let mut a = x.to_le_bytes();
|
||||
a[0] &= 0xf0;
|
||||
f32::from_ne_bytes(a)
|
||||
};
|
||||
let y = {
|
||||
let mut a = y.to_le_bytes();
|
||||
a[0] &= 0xf0;
|
||||
f32::from_ne_bytes(a)
|
||||
};
|
||||
x == y
|
||||
}
|
||||
|
||||
fn f32_iter_cmp_near<A, B>(a: A, b: B) -> bool
|
||||
where
|
||||
A: IntoIterator<Item = f32>,
|
||||
@@ -25,17 +39,7 @@ where
|
||||
let x = a.next();
|
||||
let y = b.next();
|
||||
if let (Some(x), Some(y)) = (x, y) {
|
||||
let x = {
|
||||
let mut a = x.to_ne_bytes();
|
||||
a[0] &= 0xf0;
|
||||
f32::from_ne_bytes(a)
|
||||
};
|
||||
let y = {
|
||||
let mut a = y.to_ne_bytes();
|
||||
a[0] &= 0xf0;
|
||||
f32::from_ne_bytes(a)
|
||||
};
|
||||
if x != y {
|
||||
if !f32_cmp_near(x, y) {
|
||||
return false;
|
||||
}
|
||||
} else if x.is_some() || y.is_some() {
|
||||
|
||||
Reference in New Issue
Block a user