pub trait Int: Sealed {}
pub trait Sealed:
core::fmt::Debug + core::fmt::Display + core::fmt::Binary +
Copy + Clone +
Eq + Ord +
core::hash::Hash + Default +
core::ops::Add<Self, Output=Self> + core::ops::AddAssign<Self> +
core::ops::Sub<Self, Output=Self> + core::ops::AddAssign<Self> +
core::ops::Shl<u32, Output=Self> +
core::ops::Shr<u32, Output=Self> +
core::ops::BitAnd<Output=Self> +
core::ops::BitOr<Output=Self> + core::ops::BitOrAssign +
core::ops::BitXor<Output=Self> +
core::ops::Not<Output=Self> +
core::ops::Neg<Output=Self> +
From<bool> + Into<i128>
{
type Unsigned: Unsigned;
type Double: Double<Single = Self>;
const ZERO: Self;
const ONE: Self;
const MIN: Self;
const MAX: Self;
const BITS: u32;
fn as_unsigned(self) -> Self::Unsigned;
fn of_unsigned(x: Self::Unsigned) -> Self;
fn as_u32(self) -> u32;
fn of_u32(x: u32) -> Self;
fn is_positive(self) -> bool;
fn abs(self) -> Self;
fn lshr(self, n: u32) -> Self;
fn mask_lsb(self, n: u32) -> Self;
fn mask_msb(self, n: u32) -> Self;
fn get_lsb(self) -> bool;
fn leading_zeros(self) -> u32;
unsafe fn leading_zeros_nonzero(self) -> u32;
unsafe fn leading_run_minus_one(self) -> u32;
fn not_if_negative(self, control: Self) -> Self;
fn not_if_positive(self, control: Self) -> Self;
fn wrapping_add(self, other: Self) -> Self;
fn wrapping_sub(self, other: Self) -> Self;
fn wrapping_neg(self) -> Self;
fn wrapping_abs(self) -> Self;
unsafe fn disjoint_bitor(self, other: Self) -> Self;
fn overflowing_add(self, other: Self) -> (Self, bool);
fn carrying_add(self, other: Self, carry: bool) -> (Self, bool);
fn overflowing_add_shift(self, other: Self) -> (Self, bool);
fn doubling_mul(self, other: Self) -> Self::Double;
unsafe fn shift_div_rem(self, other: Self, precision: u32) -> (Self, Self);
fn multiword_shl<const WORD_SIZE: u32>(self, n: u32) -> (Self, Self, u32);
}
pub trait Unsigned:
core::fmt::Debug + core::fmt::Display + core::fmt::Binary +
Copy + Clone +
Eq + Ord +
core::ops::Shl<u32, Output=Self> +
core::ops::Shr<u32, Output=Self> +
{
#[expect(dead_code)]
fn overflowing_add(self, other: Self) -> (Self, bool);
fn shift_sqrt(self, precision: u32) -> (Self, bool);
}
pub trait Double:
core::fmt::Debug +
Copy + Clone +
Eq + Ord +
core::ops::Shl<u32, Output=Self> +
core::ops::Shr<u32, Output=Self> +
{
type Single: Int;
fn components_hi_lo(self) -> (Self::Single, Self::Single);
unsafe fn leading_run_minus_one(self) -> u32;
fn as_int(self) -> impl Int;
}
mod int;
mod unsigned;
mod double;
mod const_as;
pub use const_as::const_as;