fastnum2/decimal/dec/
intrinsics.rs1use crate::int::{math::ilog10, UInt};
2
3pub(crate) struct Intrinsics<const N: usize>;
4
5pub(crate) const E_LIMIT: i32 = -(i16::MIN as i32);
7
8pub(crate) const E_MIN: i32 = -(i16::MAX as i32);
10
11impl<const N: usize> Intrinsics<N> {
12 pub(crate) const COEFF_MAX: UInt<N> = UInt::<N>::MAX;
13
14 pub(crate) const COEFF_MEDIUM: UInt<N> = Self::COEFF_MAX.div(UInt::<N>::TEN);
15
16 pub(crate) const MAX_CLENGTH: u32 = clength(UInt::<N>::MAX);
18
19 pub(crate) const E_MAX: i32 = E_LIMIT + (Self::MAX_CLENGTH as i32 - 1);
21
22 pub(crate) const SERIES_MAX_ITERATIONS: u32 = Self::MAX_CLENGTH * 6;
23}
24
25#[inline(always)]
26pub(crate) const fn clength<const N: usize>(coeff: UInt<N>) -> u32 {
27 if coeff.is_zero() {
28 return 1;
29 }
30
31 ilog10(coeff) + 1
32}