use crate::types::widths::{D38, D57};
use crate::support::rounding::RoundingMode;
#[inline]
#[must_use]
pub(crate) fn exp_strict<const SCALE: u32>(raw: i128, mode: RoundingMode) -> i128 {
let widened: D57<SCALE> = D38::<SCALE>::from_bits(raw).into();
let raw_wide = super::wide_kernel::exp_strict_d57(widened.0, mode, SCALE);
let wide = D57::<SCALE>::from_bits(raw_wide);
let narrowed: D38<SCALE> = wide.try_into().unwrap_or_else(|_| panic!(
"exp_strict: result out of range — produced {wide}, D38<{SCALE}> represents only |x| < 1.7e{}",
38_i32 - SCALE as i32,
));
narrowed.0
}
#[inline]
#[must_use]
pub(crate) fn exp2_strict<const SCALE: u32>(raw: i128, mode: RoundingMode) -> i128 {
let widened: D57<SCALE> = D38::<SCALE>::from_bits(raw).into();
let result = widened.exp2_strict_with(mode);
let narrowed: D38<SCALE> = result.try_into().unwrap_or_else(|_| panic!(
"exp2_strict: result out of range — produced {result}, D38<{SCALE}> represents only |x| < 1.7e{}",
38_i32 - SCALE as i32,
));
narrowed.0
}