macro_rules! common_float_impl {
($f: ident) => {
pub use $crate::decimal::utils::types::$f::*;
pub const MAX_10_EXP: i32 = $f::MAX_10_EXP;
#[allow(dead_code)]
pub const MIN_10_EXP: i32 = $f::MIN_10_EXP;
pub const SIG_TOTAL_BITS: u32 = $f::MANTISSA_DIGITS;
pub const SIG_BITS: u32 = SIG_TOTAL_BITS - 1;
pub const EXP_BITS: u32 = BITS - SIG_BITS - 1;
pub const EXP_SAT: u32 = (1 << EXP_BITS) - 1;
pub const INFINITE_POWER: i32 = EXP_SAT as i32;
pub const EXP_BIAS: u32 = EXP_SAT >> 1;
pub const EXP_MIN: i32 = -(EXP_BIAS as i32 - 1);
pub const MAX_EXPONENT_FAST_PATH: i32 = {
let log2_5 = core::f64::consts::LOG2_10 - 1.0;
(SIG_TOTAL_BITS as f64 / log2_5) as i32
};
pub const MIN_EXPONENT_FAST_PATH: i32 = -MAX_EXPONENT_FAST_PATH;
pub const MAX_EXPONENT_DISGUISED_FAST_PATH: i32 =
MAX_EXPONENT_FAST_PATH + (SIG_TOTAL_BITS as f64 / core::f64::consts::LOG2_10) as i32;
pub const MAX_MANTISSA_FAST_PATH: u64 = 1 << SIG_TOTAL_BITS;
#[inline(always)]
pub const fn from_u64(v: u64) -> $f {
debug_assert!(v <= MAX_MANTISSA_FAST_PATH);
v as _
}
};
}
pub(crate) use common_float_impl;