Skip to main content

fastnum/bint/uint/
wrapping.rs

1use crate::bint::{doc, intrinsics::ExpType, wrapping::wrapping_impl, Int, UInt};
2
3wrapping_impl!(UInt, U);
4
5#[doc = doc::wrapping::impl_desc!()]
6impl<const N: usize> UInt<N> {
7    #[doc = doc::wrapping::wrapping_add_signed!(U 256)]
8    #[must_use = doc::must_use_op!()]
9    #[inline(always)]
10    pub const fn wrapping_add_signed(self, rhs: Int<N>) -> Self {
11        Self(self.0.wrapping_add_signed(rhs.0))
12    }
13
14    #[doc = doc::wrapping::wrapping_next_power_of_two!(U 256)]
15    #[must_use = doc::must_use_op!()]
16    #[inline(always)]
17    pub const fn wrapping_next_power_of_two(self) -> Self {
18        Self(self.0.wrapping_next_power_of_two())
19    }
20
21    #[doc = doc::wrapping::wrapping_mul_digit!(U 256)]
22    #[must_use = doc::must_use_op!()]
23    #[inline]
24    pub const fn wrapping_mul_digit(self, rhs: u64) -> Self {
25        self.overflowing_mul_digit(rhs).0
26    }
27}