fastnum/bint/uint/
overflowing.rs1use crate::bint::{
2 doc,
3 overflowing::overflowing_impl,
4 uint::{intrinsics::*, math},
5 Int, UInt,
6};
7
8overflowing_impl!(UInt, U);
9
10#[doc = doc::overflowing::impl_desc!()]
11impl<const N: usize> UInt<N> {
12 #[doc = doc::overflowing::overflowing_add_signed!(U 256)]
13 #[must_use = doc::must_use_op!()]
14 #[inline(always)]
15 pub const fn overflowing_add_signed(self, rhs: Int<N>) -> (Self, bool) {
16 let (res, carry) = self.0.overflowing_add_signed(rhs.0);
17 (Self(res), carry)
18 }
19
20 #[doc = doc::overflowing::overflowing_add!(U 256)]
21 #[must_use = doc::must_use_op!()]
22 #[inline(always)]
23 pub const fn overflowing_add_digit(self, rhs: u64) -> (Self, bool) {
24 math::add::add_digit(self, rhs)
25 }
26
27 #[doc = doc::overflowing::overflowing_mul!(U 256)]
28 #[must_use = doc::must_use_op!()]
29 #[inline(always)]
30 pub const fn overflowing_mul(self, rhs: Self) -> (Self, bool) {
31 math::mul::overflowing_mul(self, rhs)
32 }
33
34 #[doc = doc::overflowing::overflowing_mul_digit!(U 256)]
35 #[must_use = doc::must_use_op!()]
36 #[inline(always)]
37 pub const fn overflowing_mul_digit(self, rhs: u64) -> (Self, bool) {
38 math::mul::overflowing_mul_digit(self, rhs)
39 }
40}