1use crate::bint::{
2 doc,
3 int::{intrinsics, math},
4 intrinsics::{Digits, ExpType},
5 num::num_impl,
6 Int, UInt,
7};
8
9num_impl!(Int, I);
10
11impl<const N: usize> Int<N> {
12 #[doc = doc::num::mul!(I 256)]
13 #[must_use = doc::must_use_op!()]
14 #[inline(always)]
15 pub const fn mul(self, rhs: Self) -> Self {
16 Self(self.0.mul(rhs.0))
17 }
18
19 #[doc = doc::num::div!(I 256)]
20 #[must_use = doc::must_use_op!()]
21 #[inline(always)]
22 pub const fn div(self, rhs: Self) -> Self {
23 Self(self.0.div(rhs.0))
24 }
25
26 #[doc = doc::num::neg!(I 256)]
27 #[must_use = doc::must_use_op!()]
28 #[inline(always)]
29 pub const fn neg(self) -> Self {
30 Self(self.0.neg())
31 }
32
33 #[doc = doc::num::from_bits!(256)]
34 #[must_use = doc::must_use_op!()]
35 #[inline(always)]
36 pub const fn from_bits(bits: UInt<N>) -> Self {
37 Self(bnum::BInt::from_bits(bits.0))
38 }
39
40 #[doc = doc::num::to_bits!(256)]
41 #[must_use = doc::must_use_op!()]
42 #[inline(always)]
43 pub const fn to_bits(self) -> UInt<N> {
44 UInt(self.0.to_bits())
45 }
46
47 #[doc = doc::num::cast_unsigned!(256)]
48 #[must_use = doc::must_use_op!()]
49 #[inline(always)]
50 pub const fn cast_unsigned(self) -> UInt<N> {
51 self.to_bits()
52 }
53
54 #[doc = doc::num::unsigned_abs!(256)]
55 #[must_use = doc::must_use_op!()]
56 #[inline(always)]
57 pub const fn unsigned_abs(self) -> UInt<N> {
58 UInt(self.0.unsigned_abs())
59 }
60
61 #[doc = doc::num::abs!(256)]
62 #[must_use = doc::must_use_op!()]
63 #[inline(always)]
64 pub const fn abs(self) -> Self {
65 Self(self.0.abs())
66 }
67
68 #[doc = doc::num::signum!(256)]
69 #[must_use = doc::must_use_op!()]
70 #[inline(always)]
71 pub const fn signum(self) -> Self {
72 Self(self.0.signum())
73 }
74
75 #[doc = doc::num::is_positive!(256)]
76 #[must_use = doc::must_use_op!()]
77 #[inline(always)]
78 pub const fn is_positive(self) -> bool {
79 self.0.is_positive()
80 }
81
82 #[doc = doc::num::is_negative!(256)]
83 #[must_use = doc::must_use_op!()]
84 #[inline(always)]
85 pub const fn is_negative(self) -> bool {
86 self.0.is_negative()
87 }
88
89 #[doc = doc::num::abs_diff!(I 256)]
90 #[must_use = doc::must_use_op!()]
91 #[inline(always)]
92 pub const fn abs_diff(self, other: Self) -> UInt<N> {
93 UInt(self.0.abs_diff(other.0))
94 }
95
96 #[doc = doc::num::div_rem!(I 256)]
97 #[must_use = doc::must_use_op!()]
98 #[inline(always)]
99 pub const fn div_rem(self, rhs: Self) -> (Self, Self) {
100 math::div_rem(self, rhs)
101 }
102
103 #[doc = doc::num::from_digits!(I 256)]
104 #[must_use = doc::must_use_op!()]
105 #[inline(always)]
106 pub const fn from_digits(digits: Digits<N>) -> Self {
107 Self(bnum::BInt::from_bits(bnum::BUint::from_digits(digits)))
108 }
109
110 #[inline(always)]
111 pub(crate) const fn last_digit_index(&self) -> usize {
112 let bits = self.to_bits();
113 bits.last_digit_index()
114 }
115
116 #[allow(unsafe_code)]
117 #[inline(always)]
118 pub(crate) const unsafe fn _transmute<const M: usize>(self) -> Int<M> {
119 intrinsics::transmute(self)
120 }
121}