fastnum/bint/uint/
strict.rs1use crate::{
2 bint::{doc, strict::strict_impl, uint::intrinsics::*, Int, UInt},
3 utils::err_msg,
4};
5
6strict_impl!(UInt, U);
7
8impl<const N: usize> UInt<N> {
9 #[doc = doc::strict::strict_add_signed!(U 256)]
10 #[must_use = doc::must_use_op!()]
11 #[inline]
12 pub const fn strict_add_signed(self, rhs: Int<N>) -> Self {
13 Self(self.0.strict_add_signed(rhs.0))
14 }
15
16 #[doc = doc::strict::strict_power_of_ten!(U 256)]
17 #[must_use = doc::must_use_op!()]
18 #[inline(always)]
19 pub const fn strict_power_of_ten(power: ExpType) -> Self {
20 Self::checked_power_of_ten(power).expect(err_msg!("power of ten is too large"))
21 }
22
23 #[doc = doc::strict::strict_power_of_five!(U 256)]
24 #[must_use = doc::must_use_op!()]
25 #[inline(always)]
26 pub const fn strict_power_of_five(power: ExpType) -> Self {
27 Self::checked_power_of_five(power).expect(err_msg!("power of five is too large"))
28 }
29
30 #[doc = doc::strict::strict_mul!(U 256)]
31 #[must_use = doc::must_use_op!()]
32 #[inline(always)]
33 pub const fn strict_mul(self, rhs: Self) -> Self {
34 self.checked_mul(rhs)
35 .expect(err_msg!("attempt to multiply with overflow"))
36 }
37
38 #[doc = doc::strict::strict_mul_digit!(U 256)]
39 #[must_use = doc::must_use_op!()]
40 #[inline(always)]
41 pub const fn strict_mul_digit(self, digit: u64) -> Self {
42 self.checked_mul_digit(digit)
43 .expect(err_msg!("attempt to multiply by digit with overflow"))
44 }
45
46 #[doc = doc::strict::strict_add!(U 256)]
47 #[must_use = doc::must_use_op!()]
48 #[inline(always)]
49 pub const fn strict_add_digit(self, digit: u64) -> Self {
50 self.checked_add_digit(digit)
51 .expect(err_msg!("attempt to add digit with overflow"))
52 }
53}