use std::cmp::Ordering;
#[inline(always)]
pub(crate) fn format_id(value: Option<usize>) -> String {
if let Some(value) = value {
value.to_string()
} else {
String::from("-")
}
}
#[inline]
pub(crate) fn ulp_comparison(a: f64, b: f64, max_ulps: u64) -> Ordering {
let mut ll_a: u64 = a.to_bits();
let mut ll_b: u64 = b.to_bits();
if ll_a < 0x8000000000000000u64 {
ll_a = 0x8000000000000000u64 - ll_a;
}
if ll_b < 0x8000000000000000u64 {
ll_b = 0x8000000000000000u64 - ll_b;
}
if ll_a > ll_b {
if ll_a - ll_b <= max_ulps {
Ordering::Equal
} else {
Ordering::Less
}
} else if ll_b - ll_a <= max_ulps {
Ordering::Equal
} else {
Ordering::Greater
}
}