Skip to main content

fastnum/bint/int/
overflowing.rs

1use crate::bint::{doc, intrinsics::*, overflowing::overflowing_impl, Int, UInt};
2
3overflowing_impl!(Int, I);
4
5#[doc = doc::overflowing::impl_desc!()]
6impl<const N: usize> Int<N> {
7    #[doc = doc::overflowing::overflowing_mul!(I 256)]
8    #[must_use = doc::must_use_op!()]
9    #[inline(always)]
10    pub const fn overflowing_mul(self, rhs: Self) -> (Self, bool) {
11        let (res, carry) = self.0.overflowing_mul(rhs.0);
12        (Self(res), carry)
13    }
14
15    #[doc = doc::overflowing::overflowing_add_unsigned!(I 256)]
16    #[must_use = doc::must_use_op!()]
17    #[inline(always)]
18    pub const fn overflowing_add_unsigned(self, rhs: UInt<N>) -> (Self, bool) {
19        let (res, carry) = self.0.overflowing_add_unsigned(rhs.0);
20        (Self(res), carry)
21    }
22
23    #[doc = doc::overflowing::overflowing_sub_unsigned!(I 256)]
24    #[must_use = doc::must_use_op!()]
25    #[inline(always)]
26    pub const fn overflowing_sub_unsigned(self, rhs: UInt<N>) -> (Self, bool) {
27        let (res, carry) = self.0.overflowing_sub_unsigned(rhs.0);
28        (Self(res), carry)
29    }
30
31    #[doc = doc::overflowing::overflowing_abs!(I 256)]
32    #[must_use = doc::must_use_op!()]
33    #[inline(always)]
34    pub const fn overflowing_abs(self) -> (Self, bool) {
35        let (res, carry) = self.0.overflowing_abs();
36        (Self(res), carry)
37    }
38}