malachite_base/num/arithmetic/mod.rs
1// Copyright © 2026 Mikhail Hogrefe
2//
3// This file is part of Malachite.
4//
5// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU
6// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version
7// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.
8
9/// [`Abs`](traits::Abs), [`AbsAssign`](traits::AbsAssign), and
10/// [`UnsignedAbs`](traits::UnsignedAbs), traits for getting the absolute value of a number.
11///
12/// # abs_assign
13/// ```
14/// use malachite_base::num::arithmetic::traits::AbsAssign;
15/// use malachite_base::num::basic::traits::NegativeInfinity;
16/// use malachite_base::num::float::NiceFloat;
17///
18/// let mut x = 0i8;
19/// x.abs_assign();
20/// assert_eq!(x, 0i8);
21///
22/// let mut x = 100i64;
23/// x.abs_assign();
24/// assert_eq!(x, 100i64);
25///
26/// let mut x = -100i64;
27/// x.abs_assign();
28/// assert_eq!(x, 100i64);
29///
30/// let mut x = -0.0;
31/// x.abs_assign();
32/// assert_eq!(NiceFloat(x), NiceFloat(0.0));
33///
34/// let mut x = f64::NEGATIVE_INFINITY;
35/// x.abs_assign();
36/// assert_eq!(NiceFloat(x), NiceFloat(f64::INFINITY));
37///
38/// let mut x = 100.0;
39/// x.abs_assign();
40/// assert_eq!(NiceFloat(x), NiceFloat(100.0));
41///
42/// let mut x = -100.0;
43/// x.abs_assign();
44/// assert_eq!(NiceFloat(x), NiceFloat(100.0));
45/// ```
46pub mod abs;
47/// [`AbsDiff`](traits::AbsDiff) and [`AbsDiffAssign`](traits::AbsDiffAssign), traits for getting
48/// the absolute value of the difference between two numbers.
49///
50/// # abs_diff
51/// ```
52/// assert_eq!(10u8.abs_diff(20u8), 10u8);
53/// assert_eq!(10i8.abs_diff(-10i8), 20u8);
54/// ```
55///
56/// # abs_diff_assign
57/// ```
58/// use malachite_base::num::arithmetic::traits::AbsDiffAssign;
59///
60/// let mut x = 10u8;
61/// x.abs_diff_assign(20u8);
62/// assert_eq!(x, 10);
63/// ```
64pub mod abs_diff;
65/// [`AddMul`](traits::AddMul) and [`AddMulAssign`](traits::AddMulAssign), traits for adding a
66/// number and the product of two other numbers.
67///
68/// # add_mul
69/// ```
70/// use malachite_base::num::arithmetic::traits::AddMul;
71///
72/// assert_eq!(2u8.add_mul(3, 7), 23);
73/// assert_eq!(127i8.add_mul(-2, 100), -73);
74/// assert_eq!(1.0f32.add_mul(2.0, 3.0), 7.0);
75/// ```
76///
77/// # add_mul_assign
78/// ```
79/// use malachite_base::num::arithmetic::traits::AddMulAssign;
80///
81/// let mut x = 2u8;
82/// x.add_mul_assign(3, 7);
83/// assert_eq!(x, 23);
84///
85/// let mut x = 127i8;
86/// x.add_mul_assign(-2, 100);
87/// assert_eq!(x, -73);
88///
89/// let mut x = 1.0f32;
90/// x.add_mul_assign(2.0, 3.0);
91/// assert_eq!(x, 7.0);
92/// ```
93pub mod add_mul;
94/// [`ArithmeticCheckedShl`](traits::ArithmeticCheckedShl), a trait for left-shifting a number and
95/// checking whether the result is representable.
96///
97/// # arithmetic_checked_shl
98/// ```
99/// use malachite_base::num::arithmetic::traits::ArithmeticCheckedShl;
100///
101/// assert_eq!(3u8.arithmetic_checked_shl(6), Some(192u8));
102/// assert_eq!(3u8.arithmetic_checked_shl(7), None);
103/// assert_eq!(3u8.arithmetic_checked_shl(100), None);
104/// assert_eq!(0u8.arithmetic_checked_shl(100), Some(0u8));
105///
106/// assert_eq!(3u8.arithmetic_checked_shl(6), Some(192u8));
107/// assert_eq!(3u8.arithmetic_checked_shl(7), None);
108/// assert_eq!(3u8.arithmetic_checked_shl(100), None);
109/// assert_eq!(0u8.arithmetic_checked_shl(100), Some(0u8));
110/// assert_eq!(100u8.arithmetic_checked_shl(-3), Some(12u8));
111/// assert_eq!(100u8.arithmetic_checked_shl(-100), Some(0u8));
112///
113/// assert_eq!(3i8.arithmetic_checked_shl(5), Some(96i8));
114/// assert_eq!(3i8.arithmetic_checked_shl(6), None);
115/// assert_eq!((-3i8).arithmetic_checked_shl(5), Some(-96i8));
116/// assert_eq!((-3i8).arithmetic_checked_shl(6), None);
117/// assert_eq!(3i8.arithmetic_checked_shl(100), None);
118/// assert_eq!((-3i8).arithmetic_checked_shl(100), None);
119/// assert_eq!(0i8.arithmetic_checked_shl(100), Some(0i8));
120///
121/// assert_eq!(3i8.arithmetic_checked_shl(5), Some(96i8));
122/// assert_eq!(3i8.arithmetic_checked_shl(6), None);
123/// assert_eq!((-3i8).arithmetic_checked_shl(5), Some(-96i8));
124/// assert_eq!((-3i8).arithmetic_checked_shl(6), None);
125/// assert_eq!(3i8.arithmetic_checked_shl(100), None);
126/// assert_eq!((-3i8).arithmetic_checked_shl(100), None);
127/// assert_eq!(0i8.arithmetic_checked_shl(100), Some(0i8));
128/// assert_eq!(100i8.arithmetic_checked_shl(-3), Some(12i8));
129/// assert_eq!((-100i8).arithmetic_checked_shl(-3), Some(-13i8));
130/// assert_eq!(100i8.arithmetic_checked_shl(-100), Some(0i8));
131/// assert_eq!((-100i8).arithmetic_checked_shl(-100), Some(-1i8));
132/// ```
133pub mod arithmetic_checked_shl;
134/// [`ArithmeticCheckedShr`](traits::ArithmeticCheckedShr), a trait for right-shifting a number and
135/// checking whether the result is representable.
136///
137/// # arithmetic_checked_shr
138/// ```
139/// use malachite_base::num::arithmetic::traits::ArithmeticCheckedShr;
140///
141/// assert_eq!(100u8.arithmetic_checked_shr(3), Some(12u8));
142/// assert_eq!(100u8.arithmetic_checked_shr(100), Some(0u8));
143/// assert_eq!(3u8.arithmetic_checked_shr(-6), Some(192u8));
144/// assert_eq!(3u8.arithmetic_checked_shr(-7), None);
145/// assert_eq!(3u8.arithmetic_checked_shr(-100), None);
146/// assert_eq!(0u8.arithmetic_checked_shr(-100), Some(0u8));
147///
148/// assert_eq!(100i8.arithmetic_checked_shr(3), Some(12i8));
149/// assert_eq!((-100i8).arithmetic_checked_shr(3), Some(-13i8));
150/// assert_eq!(100i8.arithmetic_checked_shr(100), Some(0i8));
151/// assert_eq!((-100i8).arithmetic_checked_shr(100), Some(-1i8));
152/// assert_eq!(3i8.arithmetic_checked_shr(-5), Some(96i8));
153/// assert_eq!(3i8.arithmetic_checked_shr(-6), None);
154/// assert_eq!((-3i8).arithmetic_checked_shr(-5), Some(-96i8));
155/// assert_eq!((-3i8).arithmetic_checked_shr(-6), None);
156/// assert_eq!(3i8.arithmetic_checked_shr(-100), None);
157/// assert_eq!((-3i8).arithmetic_checked_shr(-100), None);
158/// assert_eq!(0i8.arithmetic_checked_shr(-100), Some(0i8));
159/// ```
160pub mod arithmetic_checked_shr;
161/// Traits for computing the binomial coefficient of two numbers. There is a trait whose
162/// implementations panic if the result cannot be represented, and a checked trait whose
163/// implementations return `None` in that case: [`BinomialCoefficient`](traits::BinomialCoefficient)
164/// and [`CheckedBinomialCoefficient`](traits::CheckedBinomialCoefficient).
165///
166/// # binomial_coefficient
167/// ```
168/// use malachite_base::num::arithmetic::traits::BinomialCoefficient;
169///
170/// assert_eq!(u8::binomial_coefficient(3, 0), 1);
171/// assert_eq!(u8::binomial_coefficient(3, 1), 3);
172/// assert_eq!(u8::binomial_coefficient(3, 2), 3);
173/// assert_eq!(u8::binomial_coefficient(3, 3), 1);
174/// assert_eq!(u8::binomial_coefficient(10, 5), 252);
175///
176/// assert_eq!(i8::binomial_coefficient(-3, 0), 1);
177/// assert_eq!(i8::binomial_coefficient(-3, 1), -3);
178/// assert_eq!(i8::binomial_coefficient(-3, 2), 6);
179/// assert_eq!(i8::binomial_coefficient(-3, 3), -10);
180/// ```
181///
182/// # checked_binomial_coefficient
183/// ```
184/// use malachite_base::num::arithmetic::traits::CheckedBinomialCoefficient;
185///
186/// assert_eq!(u8::checked_binomial_coefficient(3, 0), Some(1));
187/// assert_eq!(u8::checked_binomial_coefficient(3, 1), Some(3));
188/// assert_eq!(u8::checked_binomial_coefficient(3, 2), Some(3));
189/// assert_eq!(u8::checked_binomial_coefficient(3, 3), Some(1));
190/// assert_eq!(u8::checked_binomial_coefficient(10, 5), Some(252));
191/// assert_eq!(u8::checked_binomial_coefficient(11, 5), None);
192///
193/// assert_eq!(i8::checked_binomial_coefficient(-3, 0), Some(1));
194/// assert_eq!(i8::checked_binomial_coefficient(-3, 1), Some(-3));
195/// assert_eq!(i8::checked_binomial_coefficient(-3, 2), Some(6));
196/// assert_eq!(i8::checked_binomial_coefficient(-3, 3), Some(-10));
197/// assert_eq!(i8::checked_binomial_coefficient(-3, -3), None);
198/// assert_eq!(i8::checked_binomial_coefficient(11, 5), None);
199/// ```
200pub mod binomial_coefficient;
201/// [`Ceiling`](traits::Ceiling) and [`CeilingAssign`](traits::CeilingAssign), traits for computing
202/// the ceiling of a number.
203///
204/// # ceiling
205/// ```
206/// use malachite_base::num::arithmetic::traits::CeilingAssign;
207///
208/// let mut x = 1.5f32;
209/// x.ceiling_assign();
210/// assert_eq!(x, 2.0);
211///
212/// let mut x = -1.5f32;
213/// x.ceiling_assign();
214/// assert_eq!(x, -1.0);
215/// ```
216pub mod ceiling;
217/// [`CheckedAbs`](traits::CheckedAbs), a trait for computing the absolute value of number and
218/// checking whether the result is representable.
219pub mod checked_abs;
220/// [`CheckedAdd`](traits::CheckedAdd), a trait for adding two numbers and checking whether the
221/// result is representable.
222pub mod checked_add;
223/// [`CheckedAddMul`](traits::CheckedAddMul), a trait for adding a number and the product of two
224/// other numbers, and checking whether the result is representable.
225///
226/// # checked_add_mul
227/// ```
228/// use malachite_base::num::arithmetic::traits::CheckedAddMul;
229///
230/// assert_eq!(2u8.checked_add_mul(3, 7), Some(23));
231/// assert_eq!(2u8.checked_add_mul(20, 20), None);
232///
233/// assert_eq!(127i8.checked_add_mul(-2, 100), Some(-73));
234/// assert_eq!((-127i8).checked_add_mul(-2, 100), None);
235/// ```
236pub mod checked_add_mul;
237/// [`CheckedDiv`](traits::CheckedDiv), a trait for dividing two numbers and checking whether the
238/// result is representable.
239pub mod checked_div;
240/// [`CheckedMul`](traits::CheckedMul), a trait for multiplying two numbers and checking whether the
241/// result is representable.
242pub mod checked_mul;
243/// [`CheckedNeg`](traits::CheckedNeg), a trait for negating a number and checking whether the
244/// result is representable.
245pub mod checked_neg;
246/// [`CheckedNextPowerOf2`](traits::CheckedNextPowerOf2), a trait for getting the next-highest power
247/// of 2, if it's representable.
248pub mod checked_next_power_of_2;
249/// [`CheckedPow`](traits::CheckedPow), a trait for raising a number to the power of a [`u64`] and
250/// checking whether the result is representable.
251pub mod checked_pow;
252/// [`CheckedSquare`](traits::CheckedSquare), a trait for squaring a number and checking whether the
253/// result is representable.
254///
255/// # checked_square
256/// ```
257/// use malachite_base::num::arithmetic::traits::CheckedSquare;
258///
259/// assert_eq!(3u8.checked_square(), Some(9));
260/// assert_eq!((-1000i32).checked_square(), Some(1000000));
261/// assert_eq!((1000u16).checked_square(), None);
262/// ```
263pub mod checked_square;
264/// [`CheckedSub`](traits::CheckedSub), a trait for subtracting two numbers and checking whether the
265/// result is representable.
266pub mod checked_sub;
267/// [`CheckedSubMul`](traits::CheckedSubMul), a trait for subtracting the product of two numbers
268/// from another number, and checking whether the result is representable.
269///
270/// # checked_sub_mul
271/// ```
272/// use malachite_base::num::arithmetic::traits::CheckedSubMul;
273///
274/// assert_eq!(60u8.checked_sub_mul(5, 10), Some(10));
275/// assert_eq!(2u8.checked_sub_mul(10, 5), None);
276///
277/// assert_eq!(127i8.checked_sub_mul(2, 100), Some(-73));
278/// assert_eq!((-127i8).checked_sub_mul(2, 100), None);
279/// ```
280pub mod checked_sub_mul;
281/// [`CoprimeWith`](traits::CoprimeWith), a trait for determining whether two numbers are coprime.
282///
283/// # coprime_with
284/// ```
285/// use malachite_base::num::arithmetic::traits::CoprimeWith;
286///
287/// assert_eq!(0u8.coprime_with(0), false);
288/// assert_eq!(0u8.coprime_with(1), true);
289/// assert_eq!(6u8.coprime_with(1), true);
290/// assert_eq!(3u8.coprime_with(5), true);
291/// assert_eq!(6u8.coprime_with(4), false);
292/// assert_eq!(6u8.coprime_with(35), true);
293/// ```
294pub mod coprime_with;
295/// [`DivEuclidean`](traits::DivEuclidean) and [`DivAssignEuclidean`](traits::DivAssignEuclidean),
296/// traits for simultaneously finding the quotient and remainder of two numbers, where the remainder
297/// is always nonnegative.
298///
299/// # div_euclidean
300/// ```
301/// use malachite_base::num::arithmetic::traits::DivEuclidean;
302///
303/// // 2 * 10 + 3 = 23
304/// assert_eq!(23u8.div_euclidean(10), (2, 3));
305///
306/// // 9 * 5 + 0 = 45
307/// assert_eq!(45u32.div_euclidean(5), (9, 0));
308///
309/// // 2 * 10 + 3 = 23
310/// assert_eq!(23i8.div_euclidean(10), (2, 3));
311///
312/// // -2 * -10 + 3 = 23
313/// assert_eq!(23i16.div_euclidean(-10), (-2, 3));
314///
315/// // -3 * 10 + 7 = -23
316/// assert_eq!((-23i32).div_euclidean(10), (-3, 7));
317///
318/// // 3 * -10 + 7 = -23
319/// assert_eq!((-23i64).div_euclidean(-10), (3, 7));
320/// ```
321///
322/// # div_assign_euclidean
323/// ```
324/// use malachite_base::num::arithmetic::traits::DivAssignEuclidean;
325///
326/// // 2 * 10 + 3 = 23
327/// let mut x = 23u8;
328/// assert_eq!(x.div_assign_euclidean(10), 3);
329/// assert_eq!(x, 2);
330///
331/// // -3 * 10 + 7 = -23
332/// let mut x = -23i32;
333/// assert_eq!(x.div_assign_euclidean(10), 7);
334/// assert_eq!(x, -3);
335///
336/// // 3 * -10 + 7 = -23
337/// let mut x = -23i64;
338/// assert_eq!(x.div_assign_euclidean(-10), 7);
339/// assert_eq!(x, 3);
340/// ```
341pub mod div_euclidean;
342/// [`DivExact`](traits::DivExact) and [`DivExactAssign`](traits::DivExactAssign), traits for
343/// dividing two numbers when it's known that the division is exact.
344///
345/// # div_exact
346/// ```
347/// use malachite_base::num::arithmetic::traits::DivExact;
348///
349/// // 123 * 456 = 56088
350/// #[allow(unstable_name_collisions)]
351/// {
352/// assert_eq!(56088u32.div_exact(456), 123);
353/// }
354///
355/// // -123 * -456 = 56088
356/// #[allow(unstable_name_collisions)]
357/// {
358/// assert_eq!(56088i64.div_exact(-456), -123);
359/// }
360/// ```
361///
362/// # div_exact_assign
363/// ```
364/// use malachite_base::num::arithmetic::traits::DivExactAssign;
365///
366/// // 123 * 456 = 56088
367/// let mut x = 56088u32;
368/// x.div_exact_assign(456);
369/// assert_eq!(x, 123);
370///
371/// // -123 * -456 = 56088
372/// let mut x = 56088i64;
373/// x.div_exact_assign(-456);
374/// assert_eq!(x, -123);
375/// ```
376pub mod div_exact;
377/// Traits for simultaneously finding the quotient and remainder of two numbers, subject to various
378/// rounding rules.
379///
380/// These are the traits:
381///
382/// | rounding | by value or reference | by mutable reference (assignment) |
383/// |--------------|---------------------------------|----------------------------------------|
384/// | towards $-\infty$ | [`DivMod`](traits::DivMod) | [`DivAssignMod`](traits::DivAssignMod) |
385/// | towards 0 | [`DivRem`](traits::DivRem) | [`DivAssignRem`](traits::DivAssignRem) |
386/// | towards $\infty$ | [`CeilingDivMod`](traits::CeilingDivMod) | [`CeilingDivAssignMod`](traits::CeilingDivAssignMod) |
387/// | towards $\infty$ | [`CeilingDivNegMod`](traits::CeilingDivNegMod) | [`CeilingDivAssignNegMod`](traits::CeilingDivAssignNegMod) |
388///
389/// [`CeilingDivMod`](traits::CeilingDivMod) and [`CeilingDivNegMod`](traits::CeilingDivNegMod) are
390/// similar. The difference is that [`CeilingDivMod`](traits::CeilingDivMod) returns a remainder
391/// less than or equal to 0, so that the usual relation $x = qy + r$ is satisfied, while
392/// [`CeilingDivNegMod`](traits::CeilingDivNegMod) returns a remainder greater than or equal to
393/// zero. This allows the remainder to have an unsigned type, but modifies the relation to $x = qy
394/// - r$.
395///
396/// # div_mod
397/// ```
398/// use malachite_base::num::arithmetic::traits::DivMod;
399///
400/// // 2 * 10 + 3 = 23
401/// assert_eq!(23u8.div_mod(10), (2, 3));
402///
403/// // 9 * 5 + 0 = 45
404/// assert_eq!(45u32.div_mod(5), (9, 0));
405///
406/// // 2 * 10 + 3 = 23
407/// assert_eq!(23i8.div_mod(10), (2, 3));
408///
409/// // -3 * -10 + -7 = 23
410/// assert_eq!(23i16.div_mod(-10), (-3, -7));
411///
412/// // -3 * 10 + 7 = -23
413/// assert_eq!((-23i32).div_mod(10), (-3, 7));
414///
415/// // 2 * -10 + -3 = -23
416/// assert_eq!((-23i64).div_mod(-10), (2, -3));
417/// ```
418///
419/// # div_assign_mod
420/// ```
421/// use malachite_base::num::arithmetic::traits::DivAssignMod;
422///
423/// // 2 * 10 + 3 = 23
424/// let mut x = 23u8;
425/// assert_eq!(x.div_assign_mod(10), 3);
426/// assert_eq!(x, 2);
427///
428/// // 9 * 5 + 0 = 45
429/// let mut x = 45u32;
430/// assert_eq!(x.div_assign_mod(5), 0);
431/// assert_eq!(x, 9);
432///
433/// // 2 * 10 + 3 = 23
434/// let mut x = 23i8;
435/// assert_eq!(x.div_assign_mod(10), 3);
436/// assert_eq!(x, 2);
437///
438/// // -3 * -10 + -7 = 23
439/// let mut x = 23i16;
440/// assert_eq!(x.div_assign_mod(-10), -7);
441/// assert_eq!(x, -3);
442///
443/// // -3 * 10 + 7 = -23
444/// let mut x = -23i32;
445/// assert_eq!(x.div_assign_mod(10), 7);
446/// assert_eq!(x, -3);
447///
448/// // 2 * -10 + -3 = -23
449/// let mut x = -23i64;
450/// assert_eq!(x.div_assign_mod(-10), -3);
451/// assert_eq!(x, 2);
452/// ```
453///
454/// # div_rem
455/// ```
456/// use malachite_base::num::arithmetic::traits::DivRem;
457///
458/// // 2 * 10 + 3 = 23
459/// assert_eq!(23u8.div_rem(10), (2, 3));
460///
461/// // 9 * 5 + 0 = 45
462/// assert_eq!(45u32.div_rem(5), (9, 0));
463///
464/// // 2 * 10 + 3 = 23
465/// assert_eq!(23i8.div_rem(10), (2, 3));
466///
467/// // -2 * -10 + 3 = 23
468/// assert_eq!(23i16.div_rem(-10), (-2, 3));
469///
470/// // -2 * 10 + -3 = -23
471/// assert_eq!((-23i32).div_rem(10), (-2, -3));
472///
473/// // 2 * -10 + -3 = -23
474/// assert_eq!((-23i64).div_rem(-10), (2, -3));
475/// ```
476///
477/// # div_assign_rem
478/// ```
479/// use malachite_base::num::arithmetic::traits::DivAssignRem;
480///
481/// // 2 * 10 + 3 = 23
482/// let mut x = 23u8;
483/// assert_eq!(x.div_assign_rem(10), 3);
484/// assert_eq!(x, 2);
485///
486/// // 9 * 5 + 0 = 45
487/// let mut x = 45u32;
488/// assert_eq!(x.div_assign_rem(5), 0);
489/// assert_eq!(x, 9);
490///
491/// // 2 * 10 + 3 = 23
492/// let mut x = 23i8;
493/// assert_eq!(x.div_assign_rem(10), 3);
494/// assert_eq!(x, 2);
495///
496/// // -2 * -10 + 3 = 23
497/// let mut x = 23i16;
498/// assert_eq!(x.div_assign_rem(-10), 3);
499/// assert_eq!(x, -2);
500///
501/// // -2 * 10 + -3 = -23
502/// let mut x = -23i32;
503/// assert_eq!(x.div_assign_rem(10), -3);
504/// assert_eq!(x, -2);
505///
506/// // 2 * -10 + -3 = -23
507/// let mut x = -23i64;
508/// assert_eq!(x.div_assign_rem(-10), -3);
509/// assert_eq!(x, 2);
510/// ```
511///
512/// # ceiling_div_neg_mod
513/// ```
514/// use malachite_base::num::arithmetic::traits::CeilingDivNegMod;
515///
516/// // 3 * 10 - 7 = 23
517/// assert_eq!(23u8.ceiling_div_neg_mod(10), (3, 7));
518///
519/// // 9 * 5 + 0 = 45
520/// assert_eq!(45u32.ceiling_div_neg_mod(5), (9, 0));
521/// ```
522///
523/// # ceiling_div_assign_neg_mod
524/// ```
525/// use malachite_base::num::arithmetic::traits::CeilingDivAssignNegMod;
526///
527/// // 3 * 10 - 7 = 23
528/// let mut x = 23u8;
529/// assert_eq!(x.ceiling_div_assign_neg_mod(10), 7);
530/// assert_eq!(x, 3);
531///
532/// // 9 * 5 + 0 = 45
533/// let mut x = 45u32;
534/// assert_eq!(x.ceiling_div_assign_neg_mod(5), 0);
535/// assert_eq!(x, 9);
536/// ```
537///
538/// # ceiling_div_mod
539/// ```
540/// use malachite_base::num::arithmetic::traits::CeilingDivMod;
541///
542/// // 3 * 10 + -7 = 23
543/// assert_eq!(23i8.ceiling_div_mod(10), (3, -7));
544///
545/// // -2 * -10 + 3 = 23
546/// assert_eq!(23i16.ceiling_div_mod(-10), (-2, 3));
547///
548/// // -2 * 10 + -3 = -23
549/// assert_eq!((-23i32).ceiling_div_mod(10), (-2, -3));
550///
551/// // 3 * -10 + 7 = -23
552/// assert_eq!((-23i64).ceiling_div_mod(-10), (3, 7));
553/// ```
554///
555/// # ceiling_div_assign_mod
556/// ```
557/// use malachite_base::num::arithmetic::traits::CeilingDivAssignMod;
558///
559/// // 3 * 10 + -7 = 23
560/// let mut x = 23i8;
561/// assert_eq!(x.ceiling_div_assign_mod(10), -7);
562/// assert_eq!(x, 3);
563///
564/// // -2 * -10 + 3 = 23
565/// let mut x = 23i16;
566/// assert_eq!(x.ceiling_div_assign_mod(-10), 3);
567/// assert_eq!(x, -2);
568///
569/// // -2 * 10 + -3 = -23
570/// let mut x = -23i32;
571/// assert_eq!(x.ceiling_div_assign_mod(10), -3);
572/// assert_eq!(x, -2);
573///
574/// // 3 * -10 + 7 = -23
575/// let mut x = -23i64;
576/// assert_eq!(x.ceiling_div_assign_mod(-10), 7);
577/// assert_eq!(x, 3);
578/// ```
579pub mod div_mod;
580/// [`DivRound`](traits::DivRound) and [`DivExactAssign`](traits::DivRoundAssign), traits for
581/// dividing two numbers according to a specified
582/// [`RoundingMode`](crate::rounding_modes::RoundingMode).
583///
584/// # div_round
585/// ```
586/// use malachite_base::num::arithmetic::traits::DivRound;
587/// use malachite_base::rounding_modes::RoundingMode::*;
588/// use std::cmp::Ordering::*;
589///
590/// assert_eq!(10u8.div_round(4, Down), (2, Less));
591/// assert_eq!(10u16.div_round(4, Up), (3, Greater));
592/// assert_eq!(10u32.div_round(5, Exact), (2, Equal));
593/// assert_eq!(10u64.div_round(3, Nearest), (3, Less));
594/// assert_eq!(20u128.div_round(3, Nearest), (7, Greater));
595/// assert_eq!(10usize.div_round(4, Nearest), (2, Less));
596/// assert_eq!(14u8.div_round(4, Nearest), (4, Greater));
597///
598/// assert_eq!((-10i8).div_round(4, Down), (-2, Greater));
599/// assert_eq!((-10i16).div_round(4, Up), (-3, Less));
600/// assert_eq!((-10i32).div_round(5, Exact), (-2, Equal));
601/// assert_eq!((-10i64).div_round(3, Nearest), (-3, Greater));
602/// assert_eq!((-20i128).div_round(3, Nearest), (-7, Less));
603/// assert_eq!((-10isize).div_round(4, Nearest), (-2, Greater));
604/// assert_eq!((-14i8).div_round(4, Nearest), (-4, Less));
605///
606/// assert_eq!((-10i16).div_round(-4, Down), (2, Less));
607/// assert_eq!((-10i32).div_round(-4, Up), (3, Greater));
608/// assert_eq!((-10i64).div_round(-5, Exact), (2, Equal));
609/// assert_eq!((-10i128).div_round(-3, Nearest), (3, Less));
610/// assert_eq!((-20isize).div_round(-3, Nearest), (7, Greater));
611/// assert_eq!((-10i8).div_round(-4, Nearest), (2, Less));
612/// assert_eq!((-14i16).div_round(-4, Nearest), (4, Greater));
613/// ```
614///
615/// # div_round_assign
616/// ```
617/// use malachite_base::num::arithmetic::traits::DivRoundAssign;
618/// use malachite_base::rounding_modes::RoundingMode::*;
619/// use std::cmp::Ordering::*;
620///
621/// let mut x = 10u8;
622/// assert_eq!(x.div_round_assign(4, Down), Less);
623/// assert_eq!(x, 2);
624///
625/// let mut x = 10u16;
626/// assert_eq!(x.div_round_assign(4, Up), Greater);
627/// assert_eq!(x, 3);
628///
629/// let mut x = 10u32;
630/// assert_eq!(x.div_round_assign(5, Exact), Equal);
631/// assert_eq!(x, 2);
632///
633/// let mut x = 10u64;
634/// assert_eq!(x.div_round_assign(3, Nearest), Less);
635/// assert_eq!(x, 3);
636///
637/// let mut x = 20u128;
638/// assert_eq!(x.div_round_assign(3, Nearest), Greater);
639/// assert_eq!(x, 7);
640///
641/// let mut x = 10usize;
642/// assert_eq!(x.div_round_assign(4, Nearest), Less);
643/// assert_eq!(x, 2);
644///
645/// let mut x = 14u8;
646/// assert_eq!(x.div_round_assign(4, Nearest), Greater);
647/// assert_eq!(x, 4);
648///
649/// let mut x = -10i8;
650/// assert_eq!(x.div_round_assign(4, Down), Greater);
651/// assert_eq!(x, -2);
652///
653/// let mut x = -10i16;
654/// assert_eq!(x.div_round_assign(4, Up), Less);
655/// assert_eq!(x, -3);
656///
657/// let mut x = -10i32;
658/// assert_eq!(x.div_round_assign(5, Exact), Equal);
659/// assert_eq!(x, -2);
660///
661/// let mut x = -10i64;
662/// assert_eq!(x.div_round_assign(3, Nearest), Greater);
663/// assert_eq!(x, -3);
664///
665/// let mut x = -20i128;
666/// assert_eq!(x.div_round_assign(3, Nearest), Less);
667/// assert_eq!(x, -7);
668///
669/// let mut x = -10isize;
670/// assert_eq!(x.div_round_assign(4, Nearest), Greater);
671/// assert_eq!(x, -2);
672///
673/// let mut x = -14i8;
674/// assert_eq!(x.div_round_assign(4, Nearest), Less);
675/// assert_eq!(x, -4);
676///
677/// let mut x = -10i16;
678/// assert_eq!(x.div_round_assign(-4, Down), Less);
679/// assert_eq!(x, 2);
680///
681/// let mut x = -10i32;
682/// assert_eq!(x.div_round_assign(-4, Up), Greater);
683/// assert_eq!(x, 3);
684///
685/// let mut x = -10i64;
686/// assert_eq!(x.div_round_assign(-5, Exact), Equal);
687/// assert_eq!(x, 2);
688///
689/// let mut x = -10i128;
690/// assert_eq!(x.div_round_assign(-3, Nearest), Less);
691/// assert_eq!(x, 3);
692///
693/// let mut x = -20isize;
694/// assert_eq!(x.div_round_assign(-3, Nearest), Greater);
695/// assert_eq!(x, 7);
696///
697/// let mut x = -10i8;
698/// assert_eq!(x.div_round_assign(-4, Nearest), Less);
699/// assert_eq!(x, 2);
700///
701/// let mut x = -14i16;
702/// assert_eq!(x.div_round_assign(-4, Nearest), Greater);
703/// assert_eq!(x, 4);
704/// ```
705pub mod div_round;
706/// [`DivisibleBy`](traits::DivisibleBy), a trait for determining whether one number is divisible by
707/// another.
708///
709/// # divisible_by
710/// ```
711/// use malachite_base::num::arithmetic::traits::DivisibleBy;
712///
713/// assert_eq!(0u8.divisible_by(0), true);
714/// assert_eq!(100u16.divisible_by(3), false);
715/// assert_eq!(102u32.divisible_by(3), true);
716///
717/// assert_eq!(0i8.divisible_by(0), true);
718/// assert_eq!((-100i16).divisible_by(-3), false);
719/// assert_eq!(102i32.divisible_by(-3), true);
720/// ```
721pub mod divisible_by;
722/// [`DivisibleByPowerOf2`](traits::DivisibleByPowerOf2), a trait for determining whether a number
723/// is divisible by $2^k$.
724///
725/// # divisible_by_power_of_2
726/// ```
727/// use malachite_base::num::arithmetic::traits::DivisibleByPowerOf2;
728///
729/// assert_eq!(0u8.divisible_by_power_of_2(100), true);
730/// assert_eq!(96u16.divisible_by_power_of_2(5), true);
731/// assert_eq!(96u32.divisible_by_power_of_2(6), false);
732///
733/// assert_eq!(0i8.divisible_by_power_of_2(100), true);
734/// assert_eq!((-96i16).divisible_by_power_of_2(5), true);
735/// assert_eq!(96i32.divisible_by_power_of_2(6), false);
736/// ```
737pub mod divisible_by_power_of_2;
738/// [`EqMod`](traits::EqMod), a trait for determining whether one number is equal by another modulo
739/// a third.
740///
741/// # eq_mod
742/// ```
743/// use malachite_base::num::arithmetic::traits::EqMod;
744///
745/// assert_eq!(123u16.eq_mod(223, 100), true);
746/// assert_eq!((-123i32).eq_mod(277, 100), true);
747/// assert_eq!((-123i64).eq_mod(278, 100), false);
748/// ```
749pub mod eq_mod;
750/// [`EqModPowerOf2`](traits::EqModPowerOf2), a trait for determining whether one number is equal to
751/// another modulo $2^k$.
752///
753/// # eq_mod_power_of_2
754/// ```
755/// use malachite_base::num::arithmetic::traits::EqModPowerOf2;
756///
757/// assert_eq!(0u16.eq_mod_power_of_2(256, 8), true);
758/// assert_eq!((-0b1101i32).eq_mod_power_of_2(0b11011, 3), true);
759/// assert_eq!((-0b1101i64).eq_mod_power_of_2(0b11011, 4), false);
760/// ```
761pub mod eq_mod_power_of_2;
762/// [`ExtendedGcd`](traits::ExtendedGcd), a trait for computing the GCD (greatest common divisor) of
763/// two numbers as well as the coefficients of Bézout's identity $ax+by=\gcd(a,b)$.
764///
765/// # extended_gcd
766/// ```
767/// use malachite_base::num::arithmetic::traits::ExtendedGcd;
768///
769/// assert_eq!(3u8.extended_gcd(5), (1, 2, -1));
770/// assert_eq!(240u16.extended_gcd(46), (2, -9, 47));
771/// assert_eq!((-111i16).extended_gcd(300), (3, 27, 10));
772/// ```
773pub mod extended_gcd;
774/// Traits for computing the factorial, double factorial, multifactorial, and subfactorial. Each
775/// function has a trait whose implementations panic if the result cannot be represented, and a
776/// checked trait whose implementations return `None` in that case. The traits are
777/// [`Factorial`](traits::Factorial), [`DoubleFactorial`](traits::DoubleFactorial),
778/// [`Multifactorial`](traits::Multifactorial), [`Subfactorial`](traits::Subfactorial),
779/// [`CheckedFactorial`](traits::CheckedFactorial),
780/// [`CheckedDoubleFactorial`](traits::CheckedDoubleFactorial),
781/// [`CheckedMultifactorial`](traits::CheckedMultifactorial), and
782/// [`CheckedSubfactorial`](traits::CheckedSubfactorial).
783///
784/// # factorial
785/// ```
786/// use malachite_base::num::arithmetic::traits::Factorial;
787///
788/// assert_eq!(u8::factorial(0), 1);
789/// assert_eq!(u8::factorial(1), 1);
790/// assert_eq!(u8::factorial(2), 2);
791/// assert_eq!(u8::factorial(3), 6);
792/// assert_eq!(u8::factorial(4), 24);
793/// assert_eq!(u8::factorial(5), 120);
794/// assert_eq!(u32::factorial(10), 3628800);
795/// ```
796///
797/// # checked_factorial
798/// ```
799/// use malachite_base::num::arithmetic::traits::CheckedFactorial;
800///
801/// assert_eq!(u8::checked_factorial(0), Some(1));
802/// assert_eq!(u8::checked_factorial(1), Some(1));
803/// assert_eq!(u8::checked_factorial(2), Some(2));
804/// assert_eq!(u8::checked_factorial(3), Some(6));
805/// assert_eq!(u8::checked_factorial(4), Some(24));
806/// assert_eq!(u8::checked_factorial(5), Some(120));
807/// assert_eq!(u8::checked_factorial(6), None);
808/// assert_eq!(u32::checked_factorial(10), Some(3628800));
809/// assert_eq!(u32::checked_factorial(100), None);
810/// ```
811///
812/// # double_factorial
813/// ```
814/// use malachite_base::num::arithmetic::traits::DoubleFactorial;
815///
816/// assert_eq!(u8::double_factorial(0), 1);
817/// assert_eq!(u8::double_factorial(1), 1);
818/// assert_eq!(u8::double_factorial(2), 2);
819/// assert_eq!(u8::double_factorial(3), 3);
820/// assert_eq!(u8::double_factorial(4), 8);
821/// assert_eq!(u8::double_factorial(5), 15);
822/// assert_eq!(u8::double_factorial(6), 48);
823/// assert_eq!(u8::double_factorial(7), 105);
824/// assert_eq!(u32::double_factorial(19), 654729075);
825/// assert_eq!(u32::double_factorial(20), 3715891200);
826/// ```
827///
828/// # checked_double_factorial
829/// ```
830/// use malachite_base::num::arithmetic::traits::CheckedDoubleFactorial;
831///
832/// assert_eq!(u8::checked_double_factorial(0), Some(1));
833/// assert_eq!(u8::checked_double_factorial(1), Some(1));
834/// assert_eq!(u8::checked_double_factorial(2), Some(2));
835/// assert_eq!(u8::checked_double_factorial(3), Some(3));
836/// assert_eq!(u8::checked_double_factorial(4), Some(8));
837/// assert_eq!(u8::checked_double_factorial(5), Some(15));
838/// assert_eq!(u8::checked_double_factorial(6), Some(48));
839/// assert_eq!(u8::checked_double_factorial(7), Some(105));
840/// assert_eq!(u8::checked_double_factorial(8), None);
841/// assert_eq!(u32::checked_double_factorial(19), Some(654729075));
842/// assert_eq!(u32::checked_double_factorial(20), Some(3715891200));
843/// assert_eq!(u32::checked_double_factorial(100), None);
844/// ```
845///
846/// # multifactorial
847/// ```
848/// use malachite_base::num::arithmetic::traits::Multifactorial;
849///
850/// assert_eq!(u8::multifactorial(0, 1), 1);
851/// assert_eq!(u8::multifactorial(1, 1), 1);
852/// assert_eq!(u8::multifactorial(2, 1), 2);
853/// assert_eq!(u8::multifactorial(3, 1), 6);
854/// assert_eq!(u8::multifactorial(4, 1), 24);
855/// assert_eq!(u8::multifactorial(5, 1), 120);
856///
857/// assert_eq!(u8::multifactorial(0, 2), 1);
858/// assert_eq!(u8::multifactorial(1, 2), 1);
859/// assert_eq!(u8::multifactorial(2, 2), 2);
860/// assert_eq!(u8::multifactorial(3, 2), 3);
861/// assert_eq!(u8::multifactorial(4, 2), 8);
862/// assert_eq!(u8::multifactorial(5, 2), 15);
863/// assert_eq!(u8::multifactorial(6, 2), 48);
864/// assert_eq!(u8::multifactorial(7, 2), 105);
865///
866/// assert_eq!(u8::multifactorial(0, 3), 1);
867/// assert_eq!(u8::multifactorial(1, 3), 1);
868/// assert_eq!(u8::multifactorial(2, 3), 2);
869/// assert_eq!(u8::multifactorial(3, 3), 3);
870/// assert_eq!(u8::multifactorial(4, 3), 4);
871/// assert_eq!(u8::multifactorial(5, 3), 10);
872/// assert_eq!(u8::multifactorial(6, 3), 18);
873/// assert_eq!(u8::multifactorial(7, 3), 28);
874/// assert_eq!(u8::multifactorial(8, 3), 80);
875/// assert_eq!(u8::multifactorial(9, 3), 162);
876///
877/// assert_eq!(u32::multifactorial(10, 1), 3628800);
878/// assert_eq!(u32::multifactorial(20, 2), 3715891200);
879/// assert_eq!(u32::multifactorial(25, 3), 608608000);
880/// ```
881///
882/// # checked_multifactorial
883/// ```
884/// use malachite_base::num::arithmetic::traits::CheckedMultifactorial;
885///
886/// assert_eq!(u8::checked_multifactorial(0, 1), Some(1));
887/// assert_eq!(u8::checked_multifactorial(1, 1), Some(1));
888/// assert_eq!(u8::checked_multifactorial(2, 1), Some(2));
889/// assert_eq!(u8::checked_multifactorial(3, 1), Some(6));
890/// assert_eq!(u8::checked_multifactorial(4, 1), Some(24));
891/// assert_eq!(u8::checked_multifactorial(5, 1), Some(120));
892/// assert_eq!(u8::checked_multifactorial(6, 1), None);
893///
894/// assert_eq!(u8::checked_multifactorial(0, 2), Some(1));
895/// assert_eq!(u8::checked_multifactorial(1, 2), Some(1));
896/// assert_eq!(u8::checked_multifactorial(2, 2), Some(2));
897/// assert_eq!(u8::checked_multifactorial(3, 2), Some(3));
898/// assert_eq!(u8::checked_multifactorial(4, 2), Some(8));
899/// assert_eq!(u8::checked_multifactorial(5, 2), Some(15));
900/// assert_eq!(u8::checked_multifactorial(6, 2), Some(48));
901/// assert_eq!(u8::checked_multifactorial(7, 2), Some(105));
902/// assert_eq!(u8::checked_multifactorial(8, 2), None);
903///
904/// assert_eq!(u8::checked_multifactorial(0, 3), Some(1));
905/// assert_eq!(u8::checked_multifactorial(1, 3), Some(1));
906/// assert_eq!(u8::checked_multifactorial(2, 3), Some(2));
907/// assert_eq!(u8::checked_multifactorial(3, 3), Some(3));
908/// assert_eq!(u8::checked_multifactorial(4, 3), Some(4));
909/// assert_eq!(u8::checked_multifactorial(5, 3), Some(10));
910/// assert_eq!(u8::checked_multifactorial(6, 3), Some(18));
911/// assert_eq!(u8::checked_multifactorial(7, 3), Some(28));
912/// assert_eq!(u8::checked_multifactorial(8, 3), Some(80));
913/// assert_eq!(u8::checked_multifactorial(9, 3), Some(162));
914/// assert_eq!(u8::checked_multifactorial(10, 3), None);
915///
916/// assert_eq!(u32::checked_multifactorial(10, 1), Some(3628800));
917/// assert_eq!(u32::checked_multifactorial(20, 2), Some(3715891200));
918/// assert_eq!(u32::checked_multifactorial(25, 3), Some(608608000));
919/// assert_eq!(u32::checked_multifactorial(100, 1), None);
920/// assert_eq!(u32::checked_multifactorial(100, 2), None);
921/// assert_eq!(u32::checked_multifactorial(100, 3), None);
922/// ```
923///
924/// # subfactorial
925/// ```
926/// use malachite_base::num::arithmetic::traits::Subfactorial;
927///
928/// assert_eq!(u8::subfactorial(0), 1);
929/// assert_eq!(u8::subfactorial(1), 0);
930/// assert_eq!(u8::subfactorial(2), 1);
931/// assert_eq!(u8::subfactorial(3), 2);
932/// assert_eq!(u8::subfactorial(4), 9);
933/// assert_eq!(u8::subfactorial(5), 44);
934/// assert_eq!(u32::subfactorial(10), 1334961);
935/// ```
936///
937/// # checked_subfactorial
938/// ```
939/// use malachite_base::num::arithmetic::traits::CheckedSubfactorial;
940///
941/// assert_eq!(u8::checked_subfactorial(0), Some(1));
942/// assert_eq!(u8::checked_subfactorial(1), Some(0));
943/// assert_eq!(u8::checked_subfactorial(2), Some(1));
944/// assert_eq!(u8::checked_subfactorial(3), Some(2));
945/// assert_eq!(u8::checked_subfactorial(4), Some(9));
946/// assert_eq!(u8::checked_subfactorial(5), Some(44));
947/// assert_eq!(u8::checked_subfactorial(6), None);
948/// assert_eq!(u32::checked_subfactorial(10), Some(1334961));
949/// assert_eq!(u32::checked_subfactorial(100), None);
950/// ```
951pub mod factorial;
952/// [`Floor`](traits::Floor) and [`FloorAssign`](traits::FloorAssign), traits for computing the
953/// floor of a number.
954///
955/// # floor_assign
956/// ```
957/// use malachite_base::num::arithmetic::traits::FloorAssign;
958///
959/// let mut x = 1.5f32;
960/// x.floor_assign();
961/// assert_eq!(x, 1.0);
962///
963/// let mut x = -1.5f32;
964/// x.floor_assign();
965/// assert_eq!(x, -2.0);
966/// ```
967pub mod floor;
968/// [`Gcd`](traits::Gcd) and [`GcdAssign`](traits::GcdAssign), traits for computing the GCD
969/// (greatest common divisor) of two numbers.
970///
971/// # gcd
972/// ```
973/// use malachite_base::num::arithmetic::traits::Gcd;
974///
975/// assert_eq!(3u8.gcd(5), 1);
976/// assert_eq!(12u16.gcd(90), 6);
977/// ```
978///
979/// # gcd_assign
980/// ```
981/// use malachite_base::num::arithmetic::traits::GcdAssign;
982///
983/// let mut x = 3u8;
984/// x.gcd_assign(5);
985/// assert_eq!(x, 1);
986///
987/// let mut x = 12u16;
988/// x.gcd_assign(90);
989/// assert_eq!(x, 6);
990/// ```
991pub mod gcd;
992/// [`IsPowerOf2`](traits::IsPowerOf2), a trait for determining whether a number is an integer power
993/// of 2.
994///
995/// # is_power_of_2
996/// ```
997/// use malachite_base::num::arithmetic::traits::IsPowerOf2;
998///
999/// assert_eq!(4.0.is_power_of_2(), true);
1000/// assert_eq!(0.25.is_power_of_2(), true);
1001/// assert_eq!(0.2.is_power_of_2(), false);
1002/// assert_eq!((-4.0).is_power_of_2(), false);
1003/// ```
1004pub mod is_power_of_2;
1005/// [`LegendreSymbol`](traits::LegendreSymbol), [`JacobiSymbol`](traits::JacobiSymbol), and
1006/// [`KroneckerSymbol`](traits::KroneckerSymbol), traits for computing the Legendre, Jacobi, and
1007/// Kronecker symbols of two numbers.
1008///
1009/// # legendre_symbol
1010/// ```
1011/// use malachite_base::num::arithmetic::traits::LegendreSymbol;
1012///
1013/// assert_eq!(10u8.legendre_symbol(5), 0);
1014/// assert_eq!(7u8.legendre_symbol(5), -1);
1015/// assert_eq!(11u8.legendre_symbol(5), 1);
1016///
1017/// assert_eq!((-7i8).legendre_symbol(5), -1);
1018/// assert_eq!((-11i8).legendre_symbol(5), 1);
1019/// ```
1020///
1021/// # jacobi_symbol
1022/// ```
1023/// use malachite_base::num::arithmetic::traits::JacobiSymbol;
1024///
1025/// assert_eq!(10u8.jacobi_symbol(5), 0);
1026/// assert_eq!(7u8.jacobi_symbol(5), -1);
1027/// assert_eq!(11u8.jacobi_symbol(5), 1);
1028/// assert_eq!(11u8.jacobi_symbol(9), 1);
1029///
1030/// assert_eq!((-7i8).jacobi_symbol(5), -1);
1031/// assert_eq!((-11i8).jacobi_symbol(5), 1);
1032/// assert_eq!((-11i8).jacobi_symbol(9), 1);
1033/// ```
1034///
1035/// # kronecker_symbol
1036/// ```
1037/// use malachite_base::num::arithmetic::traits::KroneckerSymbol;
1038///
1039/// assert_eq!(10u8.kronecker_symbol(5), 0);
1040/// assert_eq!(7u8.kronecker_symbol(5), -1);
1041/// assert_eq!(11u8.kronecker_symbol(5), 1);
1042/// assert_eq!(11u8.kronecker_symbol(9), 1);
1043/// assert_eq!(11u8.kronecker_symbol(8), -1);
1044///
1045/// assert_eq!((-7i8).kronecker_symbol(5), -1);
1046/// assert_eq!((-11i8).kronecker_symbol(5), 1);
1047/// assert_eq!((-11i8).kronecker_symbol(9), 1);
1048/// assert_eq!((-11i8).kronecker_symbol(8), -1);
1049/// assert_eq!((-11i8).kronecker_symbol(-8), 1);
1050/// ```
1051pub mod kronecker_symbol;
1052/// [`Lcm`](traits::Lcm), [`LcmAssign`](traits::LcmAssign), and [`CheckedLcm`](traits::CheckedLcm),
1053/// traits for computing the LCM (least common multiple) of two numbers.
1054///
1055/// # lcm
1056/// ```
1057/// use malachite_base::num::arithmetic::traits::Lcm;
1058///
1059/// assert_eq!(3u8.lcm(5), 15);
1060/// assert_eq!(12u16.lcm(90), 180);
1061/// ```
1062///
1063/// # lcm_assign
1064/// ```
1065/// use malachite_base::num::arithmetic::traits::LcmAssign;
1066///
1067/// let mut x = 3u8;
1068/// x.lcm_assign(5);
1069/// assert_eq!(x, 15);
1070///
1071/// let mut x = 12u16;
1072/// x.lcm_assign(90);
1073/// assert_eq!(x, 180);
1074/// ```
1075///
1076/// # checked_lcm
1077/// ```
1078/// use malachite_base::num::arithmetic::traits::CheckedLcm;
1079///
1080/// assert_eq!(3u8.checked_lcm(5), Some(15));
1081/// assert_eq!(12u16.checked_lcm(90), Some(180));
1082/// assert_eq!(120u8.checked_lcm(90), None);
1083/// ```
1084pub mod lcm;
1085/// Traits for taking the base-$b$ logarithm of a number.
1086///
1087/// The traits are [`FloorLogBase`](traits::FloorLogBase),
1088/// [`CeilingLogBase`](traits::CeilingLogBase), and [`CheckedLogBase`](traits::CheckedLogBase).
1089///
1090/// # floor_log_base
1091/// ```
1092/// use malachite_base::num::arithmetic::traits::FloorLogBase;
1093///
1094/// assert_eq!(1u8.floor_log_base(5), 0);
1095/// assert_eq!(125u8.floor_log_base(5), 3);
1096/// assert_eq!(99u64.floor_log_base(10), 1);
1097/// assert_eq!(100u64.floor_log_base(10), 2);
1098/// assert_eq!(101u64.floor_log_base(10), 2);
1099/// ```
1100///
1101/// # ceiling_log_base
1102/// ```
1103/// use malachite_base::num::arithmetic::traits::CeilingLogBase;
1104///
1105/// assert_eq!(1u8.ceiling_log_base(5), 0);
1106/// assert_eq!(125u8.ceiling_log_base(5), 3);
1107/// assert_eq!(99u64.ceiling_log_base(10), 2);
1108/// assert_eq!(100u64.ceiling_log_base(10), 2);
1109/// assert_eq!(101u64.ceiling_log_base(10), 3);
1110/// ```
1111///
1112/// # checked_log_base
1113/// ```
1114/// use malachite_base::num::arithmetic::traits::CheckedLogBase;
1115///
1116/// assert_eq!(1u8.checked_log_base(5), Some(0));
1117/// assert_eq!(125u8.checked_log_base(5), Some(3));
1118/// assert_eq!(99u64.checked_log_base(10), None);
1119/// assert_eq!(100u64.checked_log_base(10), Some(2));
1120/// assert_eq!(101u64.checked_log_base(10), None);
1121/// ```
1122pub mod log_base;
1123/// Traits for taking the base-2 logarithm of a number.
1124///
1125/// The traits are [`FloorLogBase2`](traits::FloorLogBase2),
1126/// [`CeilingLogBase2`](traits::CeilingLogBase2), and [`CheckedLogBase2`](traits::CheckedLogBase2).
1127///
1128/// # floor_log_base_2
1129/// ```
1130/// use malachite_base::num::arithmetic::traits::FloorLogBase2;
1131///
1132/// assert_eq!(1u8.floor_log_base_2(), 0);
1133/// assert_eq!(100u64.floor_log_base_2(), 6);
1134///
1135/// assert_eq!(1.0f32.floor_log_base_2(), 0);
1136/// assert_eq!(100.0f32.floor_log_base_2(), 6);
1137/// assert_eq!(0.1f32.floor_log_base_2(), -4);
1138/// ```
1139///
1140/// # ceiling_log_base_2
1141/// ```
1142/// use malachite_base::num::arithmetic::traits::CeilingLogBase2;
1143///
1144/// assert_eq!(1u8.ceiling_log_base_2(), 0);
1145/// assert_eq!(100u64.ceiling_log_base_2(), 7);
1146///
1147/// assert_eq!(1.0f32.ceiling_log_base_2(), 0);
1148/// assert_eq!(100.0f32.ceiling_log_base_2(), 7);
1149/// assert_eq!(0.1f32.ceiling_log_base_2(), -3);
1150/// ```
1151///
1152/// # checked_log_base_2
1153/// ```
1154/// use malachite_base::num::arithmetic::traits::CheckedLogBase2;
1155///
1156/// assert_eq!(1u8.checked_log_base_2(), Some(0));
1157/// assert_eq!(100u64.checked_log_base_2(), None);
1158/// assert_eq!(128u64.checked_log_base_2(), Some(7));
1159///
1160/// assert_eq!(1.0f32.checked_log_base_2(), Some(0));
1161/// assert_eq!(100.0f32.checked_log_base_2(), None);
1162/// assert_eq!(128.0f32.checked_log_base_2(), Some(7));
1163/// assert_eq!(0.1f32.checked_log_base_2(), None);
1164/// assert_eq!(0.0625f32.checked_log_base_2(), Some(-4));
1165/// ```
1166pub mod log_base_2;
1167/// Traits for taking the base-$2^k$ logarithm of a number.
1168///
1169/// The traits are [`FloorLogBasePowerOf2`](traits::FloorLogBasePowerOf2),
1170/// [`CeilingLogBasePowerOf2`](traits::CeilingLogBasePowerOf2), and
1171/// [`CheckedLogBasePowerOf2`](traits::CheckedLogBasePowerOf2).
1172///
1173/// # floor_log_base_power_of_2
1174/// ```
1175/// use malachite_base::num::arithmetic::traits::FloorLogBasePowerOf2;
1176///
1177/// assert_eq!(1u8.floor_log_base_power_of_2(4), 0);
1178/// assert_eq!(100u64.floor_log_base_power_of_2(2), 3);
1179///
1180/// assert_eq!(0.1f32.floor_log_base_power_of_2(2), -2);
1181/// ```
1182///
1183/// # ceiling_log_base_power_of_2
1184/// ```
1185/// use malachite_base::num::arithmetic::traits::CeilingLogBasePowerOf2;
1186///
1187/// assert_eq!(1u8.ceiling_log_base_power_of_2(4), 0);
1188/// assert_eq!(100u64.ceiling_log_base_power_of_2(2), 4);
1189///
1190/// assert_eq!(0.1f32.ceiling_log_base_power_of_2(2), -1);
1191/// ```
1192///
1193/// # checked_log_base_power_of_2
1194/// ```
1195/// use malachite_base::num::arithmetic::traits::CheckedLogBasePowerOf2;
1196///
1197/// assert_eq!(1u8.checked_log_base_power_of_2(4), Some(0));
1198/// assert_eq!(100u64.checked_log_base_power_of_2(4), None);
1199/// assert_eq!(256u64.checked_log_base_power_of_2(4), Some(2));
1200///
1201/// assert_eq!(0.1f32.checked_log_base_power_of_2(2), None);
1202/// assert_eq!(0.0625f32.checked_log_base_power_of_2(2), Some(-2));
1203/// ```
1204pub mod log_base_power_of_2;
1205/// [`ModAdd`](traits::ModAdd) and [`ModAddAssign`](traits::ModAddAssign), traits for adding two
1206/// numbers modulo another number.
1207///
1208/// # mod_add
1209/// ```
1210/// use malachite_base::num::arithmetic::traits::ModAdd;
1211///
1212/// assert_eq!(0u8.mod_add(3, 5), 3);
1213/// assert_eq!(7u32.mod_add(5, 10), 2);
1214/// ```
1215///
1216/// # mod_add_assign
1217/// ```
1218/// use malachite_base::num::arithmetic::traits::ModAddAssign;
1219///
1220/// let mut n = 0u8;
1221/// n.mod_add_assign(3, 5);
1222/// assert_eq!(n, 3);
1223///
1224/// let mut n = 7u32;
1225/// n.mod_add_assign(5, 10);
1226/// assert_eq!(n, 2);
1227/// ```
1228pub mod mod_add;
1229/// [`ModInverse`](traits::ModInverse), a trait for finding the multiplicative inverse of a number
1230/// modulo another number.
1231///
1232/// # mod_inverse
1233/// ```
1234/// use malachite_base::num::arithmetic::traits::ModInverse;
1235///
1236/// assert_eq!(7u8.mod_inverse(10), Some(3));
1237/// assert_eq!(8u8.mod_inverse(10), None);
1238/// assert_eq!(123u32.mod_inverse(4567), Some(854));
1239/// ```
1240pub mod mod_inverse;
1241/// [`ModIsReduced`](traits::ModIsReduced), a trait for checking whether a number is reduced modulo
1242/// another number.
1243///
1244/// # mod_is_reduced
1245/// ```
1246/// use malachite_base::num::arithmetic::traits::ModIsReduced;
1247///
1248/// assert_eq!(0u8.mod_is_reduced(&5), true);
1249/// assert_eq!(100u64.mod_is_reduced(&100), false);
1250/// assert_eq!(100u16.mod_is_reduced(&101), true);
1251/// ```
1252pub mod mod_is_reduced;
1253/// Traits for multiplying two numbers modulo another number.
1254///
1255/// The traits are [`ModMul`](traits::ModMul), [`ModMulAssign`](traits::ModMulAssign),
1256/// [`ModMulPrecomputed`](traits::ModMulPrecomputed), and
1257/// [`ModMulPrecomputedAssign`](traits::ModMulPrecomputedAssign).
1258/// [`ModMulPrecomputed`](traits::ModMulPrecomputed) and
1259/// [`ModMulPrecomputedAssign`](traits::ModMulPrecomputedAssign) are useful when having to make
1260/// several multiplications modulo the same modulus.
1261///
1262/// # mod_mul
1263/// ```
1264/// use malachite_base::num::arithmetic::traits::ModMul;
1265///
1266/// assert_eq!(2u8.mod_mul(3, 7), 6);
1267/// assert_eq!(7u32.mod_mul(3, 10), 1);
1268/// ```
1269///
1270/// # mod_mul_assign
1271/// ```
1272/// use malachite_base::num::arithmetic::traits::ModMulAssign;
1273///
1274/// let mut n = 2u8;
1275/// n.mod_mul_assign(3, 7);
1276/// assert_eq!(n, 6);
1277///
1278/// let mut n = 7u32;
1279/// n.mod_mul_assign(3, 10);
1280/// assert_eq!(n, 1);
1281/// ```
1282///
1283/// # mod_mul_precomputed
1284/// ```
1285/// use malachite_base::num::arithmetic::traits::ModMulPrecomputed;
1286///
1287/// let data = u32::precompute_mod_mul_data(&7);
1288/// assert_eq!(2u32.mod_mul_precomputed(3, 7, &data), 6);
1289/// assert_eq!(5u32.mod_mul_precomputed(3, 7, &data), 1);
1290/// assert_eq!(4u32.mod_mul_precomputed(4, 7, &data), 2);
1291///
1292/// let data = u64::precompute_mod_mul_data(&10);
1293/// assert_eq!(7u64.mod_mul_precomputed(3, 10, &data), 1);
1294/// assert_eq!(4u64.mod_mul_precomputed(9, 10, &data), 6);
1295/// assert_eq!(5u64.mod_mul_precomputed(8, 10, &data), 0);
1296///
1297/// let data = u8::precompute_mod_mul_data(&7);
1298/// assert_eq!(2u8.mod_mul_precomputed(3, 7, &data), 6);
1299/// assert_eq!(5u8.mod_mul_precomputed(3, 7, &data), 1);
1300/// assert_eq!(4u8.mod_mul_precomputed(4, 7, &data), 2);
1301///
1302/// let data = u16::precompute_mod_mul_data(&10);
1303/// assert_eq!(7u16.mod_mul_precomputed(3, 10, &data), 1);
1304/// assert_eq!(4u16.mod_mul_precomputed(9, 10, &data), 6);
1305/// assert_eq!(5u16.mod_mul_precomputed(8, 10, &data), 0);
1306///
1307/// let data = u128::precompute_mod_mul_data(&7);
1308/// assert_eq!(2u128.mod_mul_precomputed(3, 7, &data), 6);
1309/// assert_eq!(5u128.mod_mul_precomputed(3, 7, &data), 1);
1310/// assert_eq!(4u128.mod_mul_precomputed(4, 7, &data), 2);
1311///
1312/// let data = u128::precompute_mod_mul_data(&10);
1313/// assert_eq!(7u128.mod_mul_precomputed(3, 10, &data), 1);
1314/// assert_eq!(4u128.mod_mul_precomputed(9, 10, &data), 6);
1315/// assert_eq!(5u128.mod_mul_precomputed(8, 10, &data), 0);
1316/// ```
1317///
1318/// # mod_mul_precomputed_assign
1319/// ```
1320/// use malachite_base::num::arithmetic::traits::{ModMulPrecomputed, ModMulPrecomputedAssign};
1321///
1322/// let data = u8::precompute_mod_mul_data(&7);
1323///
1324/// let mut x = 2u8;
1325/// x.mod_mul_precomputed_assign(3, 7, &data);
1326/// assert_eq!(x, 6);
1327///
1328/// let mut x = 5u8;
1329/// x.mod_mul_precomputed_assign(3, 7, &data);
1330/// assert_eq!(x, 1);
1331///
1332/// let mut x = 4u8;
1333/// x.mod_mul_precomputed_assign(4, 7, &data);
1334/// assert_eq!(x, 2);
1335///
1336/// let data = u32::precompute_mod_mul_data(&10);
1337///
1338/// let mut x = 7u32;
1339/// x.mod_mul_precomputed_assign(3, 10, &data);
1340/// assert_eq!(x, 1);
1341///
1342/// let mut x = 4u32;
1343/// x.mod_mul_precomputed_assign(9, 10, &data);
1344/// assert_eq!(x, 6);
1345///
1346/// let mut x = 5u32;
1347/// x.mod_mul_precomputed_assign(8, 10, &data);
1348/// assert_eq!(x, 0);
1349/// ```
1350pub mod mod_mul;
1351/// [`ModNeg`](traits::ModNeg) and [`ModNegAssign`](traits::ModNegAssign), traits for negating a
1352/// number modulo another number.
1353///
1354/// # mod_neg
1355/// ```
1356/// use malachite_base::num::arithmetic::traits::ModNeg;
1357///
1358/// assert_eq!(0u8.mod_neg(5), 0);
1359/// assert_eq!(7u32.mod_neg(10), 3);
1360/// assert_eq!(100u16.mod_neg(101), 1);
1361/// ```
1362///
1363/// # mod_neg_assign
1364/// ```
1365/// use malachite_base::num::arithmetic::traits::ModNegAssign;
1366///
1367/// let mut n = 0u8;
1368/// n.mod_neg_assign(5);
1369/// assert_eq!(n, 0);
1370///
1371/// let mut n = 7u32;
1372/// n.mod_neg_assign(10);
1373/// assert_eq!(n, 3);
1374///
1375/// let mut n = 100u16;
1376/// n.mod_neg_assign(101);
1377/// assert_eq!(n, 1);
1378/// ```
1379pub mod mod_neg;
1380/// Traits for finding the remainder of two numbers, subject to various rounding rules.
1381///
1382/// These are the traits:
1383///
1384/// | rounding | by value or reference | by mutable reference (assignment) |
1385/// |-------------------|----------------------------|----------------------------------------|
1386/// | towards $-\infty$ | [`Mod`](traits::Mod) | [`ModAssign`](traits::ModAssign) |
1387/// | towards $\infty$ | [`CeilingMod`](traits::CeilingMod) | [`CeilingModAssign`](traits::CeilingModAssign) |
1388/// | towards $\infty$ | [`NegMod`](traits::NegMod) | [`NegModAssign`](traits::NegModAssign) |
1389///
1390/// [`CeilingMod`](traits::CeilingMod) and [`NegMod`](traits::NegMod) are similar. The difference is
1391/// that [`CeilingMod`](traits::CeilingMod) returns a remainder less than or equal to 0, so that the
1392/// usual relation $x = qy + r$ is satisfied, while [`NegMod`](traits::NegMod) returns a remainder
1393/// greater than or equal to zero. This allows the remainder to have an unsigned type, but modifies
1394/// the relation to $x = qy - r$.
1395///
1396/// The [`Rem`](std::ops::Rem) trait in the standard library rounds towards 0.
1397///
1398/// # mod_op
1399/// ```
1400/// use malachite_base::num::arithmetic::traits::Mod;
1401///
1402/// // 2 * 10 + 3 = 23
1403/// assert_eq!(23u8.mod_op(10), 3);
1404///
1405/// // 9 * 5 + 0 = 45
1406/// assert_eq!(45u32.mod_op(5), 0);
1407///
1408/// // 2 * 10 + 3 = 23
1409/// assert_eq!(23i8.mod_op(10), 3);
1410///
1411/// // -3 * -10 + -7 = 23
1412/// assert_eq!(23i16.mod_op(-10), -7);
1413///
1414/// // -3 * 10 + 7 = -23
1415/// assert_eq!((-23i32).mod_op(10), 7);
1416///
1417/// // 2 * -10 + -3 = -23
1418/// assert_eq!((-23i64).mod_op(-10), -3);
1419/// ```
1420///
1421/// # mod_assign
1422/// ```
1423/// use malachite_base::num::arithmetic::traits::ModAssign;
1424///
1425/// // 2 * 10 + 3 = 23
1426/// let mut x = 23u8;
1427/// x.mod_assign(10);
1428/// assert_eq!(x, 3);
1429///
1430/// // 9 * 5 + 0 = 45
1431/// let mut x = 45u32;
1432/// x.mod_assign(5);
1433/// assert_eq!(x, 0);
1434///
1435/// // 2 * 10 + 3 = 23
1436/// let mut x = 23i8;
1437/// x.mod_assign(10);
1438/// assert_eq!(x, 3);
1439///
1440/// // -3 * -10 + -7 = 23
1441/// let mut x = 23i16;
1442/// x.mod_assign(-10);
1443/// assert_eq!(x, -7);
1444///
1445/// // -3 * 10 + 7 = -23
1446/// let mut x = -23i32;
1447/// x.mod_assign(10);
1448/// assert_eq!(x, 7);
1449///
1450/// // 2 * -10 + -3 = -23
1451/// let mut x = -23i64;
1452/// x.mod_assign(-10);
1453/// assert_eq!(x, -3);
1454/// ```
1455///
1456/// # neg_mod
1457/// ```
1458/// use malachite_base::num::arithmetic::traits::NegMod;
1459///
1460/// // 3 * 10 - 7 = 23
1461/// assert_eq!(23u8.neg_mod(10), 7);
1462///
1463/// // 9 * 5 + 0 = 45
1464/// assert_eq!(45u32.neg_mod(5), 0);
1465/// ```
1466///
1467/// # neg_mod_assign
1468/// ```
1469/// use malachite_base::num::arithmetic::traits::NegModAssign;
1470///
1471/// // 3 * 10 - 7 = 23
1472/// let mut x = 23u8;
1473/// x.neg_mod_assign(10);
1474/// assert_eq!(x, 7);
1475///
1476/// // 9 * 5 + 0 = 45
1477/// let mut x = 45u32;
1478/// x.neg_mod_assign(5);
1479/// assert_eq!(x, 0);
1480/// ```
1481///
1482/// # ceiling_mod
1483/// ```
1484/// use malachite_base::num::arithmetic::traits::CeilingMod;
1485///
1486/// // 3 * 10 + -7 = 23
1487/// assert_eq!(23i8.ceiling_mod(10), -7);
1488///
1489/// // -2 * -10 + 3 = 23
1490/// assert_eq!(23i16.ceiling_mod(-10), 3);
1491///
1492/// // -2 * 10 + -3 = -23
1493/// assert_eq!((-23i32).ceiling_mod(10), -3);
1494///
1495/// // 3 * -10 + 7 = -23
1496/// assert_eq!((-23i64).ceiling_mod(-10), 7);
1497/// ```
1498///
1499/// # ceiling_mod_assign
1500/// ```
1501/// use malachite_base::num::arithmetic::traits::CeilingModAssign;
1502///
1503/// // 3 * 10 + -7 = 23
1504/// let mut x = 23i8;
1505/// x.ceiling_mod_assign(10);
1506/// assert_eq!(x, -7);
1507///
1508/// // -2 * -10 + 3 = 23
1509/// let mut x = 23i16;
1510/// x.ceiling_mod_assign(-10);
1511/// assert_eq!(x, 3);
1512///
1513/// // -2 * 10 + -3 = -23
1514/// let mut x = -23i32;
1515/// x.ceiling_mod_assign(10);
1516/// assert_eq!(x, -3);
1517///
1518/// // 3 * -10 + 7 = -23
1519/// let mut x = -23i64;
1520/// x.ceiling_mod_assign(-10);
1521/// assert_eq!(x, 7);
1522/// ```
1523pub mod mod_op;
1524/// Traits for raising a number to a power modulo another number.
1525///
1526/// The traits are [`ModPow`](traits::ModPow), [`ModPowAssign`](traits::ModPowAssign), and
1527/// [`ModPowPrecomputed`](traits::ModPowPrecomputed).
1528/// [`ModPowPrecomputed`](traits::ModPowPrecomputed) is useful when having to make several
1529/// exponentiations modulo the same modulus.
1530///
1531/// # mod_pow
1532/// ```
1533/// use malachite_base::num::arithmetic::traits::ModPow;
1534///
1535/// assert_eq!(4u16.mod_pow(13, 497), 445);
1536/// assert_eq!(10u32.mod_pow(1000, 30), 10);
1537/// ```
1538///
1539/// # mod_pow_assign
1540/// ```
1541/// use malachite_base::num::arithmetic::traits::ModPowAssign;
1542///
1543/// let mut n = 4u16;
1544/// n.mod_pow_assign(13, 497);
1545/// assert_eq!(n, 445);
1546///
1547/// let mut n = 10u32;
1548/// n.mod_pow_assign(1000, 30);
1549/// assert_eq!(n, 10);
1550/// ```
1551///
1552/// # mod_pow_precomputed
1553/// ```
1554/// use malachite_base::num::arithmetic::traits::ModPowPrecomputed;
1555///
1556/// let data = u32::precompute_mod_pow_data(&497);
1557/// assert_eq!(4u32.mod_pow_precomputed(13, 497, &data), 445);
1558/// assert_eq!(5u32.mod_pow_precomputed(3, 497, &data), 125);
1559/// assert_eq!(4u32.mod_pow_precomputed(100, 497, &data), 116);
1560///
1561/// let data = u64::precompute_mod_pow_data(&30);
1562/// assert_eq!(10u64.mod_pow_precomputed(1000, 30, &data), 10);
1563/// assert_eq!(4u64.mod_pow_precomputed(9, 30, &data), 4);
1564/// assert_eq!(5u64.mod_pow_precomputed(8, 30, &data), 25);
1565///
1566/// let data = u16::precompute_mod_pow_data(&497);
1567/// assert_eq!(4u16.mod_pow_precomputed(13, 497, &data), 445);
1568/// assert_eq!(5u16.mod_pow_precomputed(3, 497, &data), 125);
1569/// assert_eq!(4u16.mod_pow_precomputed(100, 497, &data), 116);
1570///
1571/// let data = u8::precompute_mod_pow_data(&30);
1572/// assert_eq!(10u8.mod_pow_precomputed(1000, 30, &data), 10);
1573/// assert_eq!(4u8.mod_pow_precomputed(9, 30, &data), 4);
1574/// assert_eq!(5u8.mod_pow_precomputed(8, 30, &data), 25);
1575///
1576/// let data = u128::precompute_mod_pow_data(&497);
1577/// assert_eq!(4u128.mod_pow_precomputed(13, 497, &data), 445);
1578/// assert_eq!(5u128.mod_pow_precomputed(3, 497, &data), 125);
1579/// assert_eq!(4u128.mod_pow_precomputed(100, 497, &data), 116);
1580///
1581/// let data = u128::precompute_mod_pow_data(&30);
1582/// assert_eq!(10u128.mod_pow_precomputed(1000, 30, &data), 10);
1583/// assert_eq!(4u128.mod_pow_precomputed(9, 30, &data), 4);
1584/// assert_eq!(5u128.mod_pow_precomputed(8, 30, &data), 25);
1585/// ```
1586///
1587/// # mod_pow_precomputed_assign
1588/// ```
1589/// use malachite_base::num::arithmetic::traits::{ModPowPrecomputed, ModPowPrecomputedAssign};
1590///
1591/// let data = u32::precompute_mod_pow_data(&497);
1592///
1593/// let mut x = 4u32;
1594/// x.mod_pow_precomputed_assign(13, 497, &data);
1595/// assert_eq!(x, 445);
1596///
1597/// let mut x = 5u32;
1598/// x.mod_pow_precomputed_assign(3, 497, &data);
1599/// assert_eq!(x, 125);
1600///
1601/// let mut x = 4u32;
1602/// x.mod_pow_precomputed_assign(100, 497, &data);
1603/// assert_eq!(x, 116);
1604///
1605/// let data = u64::precompute_mod_pow_data(&30);
1606///
1607/// let mut x = 10u64;
1608/// x.mod_pow_precomputed_assign(1000, 30, &data);
1609/// assert_eq!(x, 10);
1610///
1611/// let mut x = 4u64;
1612/// x.mod_pow_precomputed_assign(9, 30, &data);
1613/// assert_eq!(x, 4);
1614///
1615/// let mut x = 5u64;
1616/// x.mod_pow_precomputed_assign(8, 30, &data);
1617/// assert_eq!(x, 25);
1618/// ```
1619pub mod mod_pow;
1620/// Traits for finding the remainder of a number divided by $2^k$, subject to various rounding
1621/// rules.
1622///
1623/// These are the traits:
1624///
1625/// | rounding | by value or reference | by mutable reference (assignment) |
1626/// |----------|-----------------------|-----------------------------------|
1627/// | towards $-\infty$ | [`ModPowerOf2`](traits::ModPowerOf2) | [`ModPowerOf2Assign`](traits::ModPowerOf2Assign) |
1628/// | towards 0 | [`RemPowerOf2`](traits::RemPowerOf2) | [`RemPowerOf2Assign`](traits::RemPowerOf2Assign) |
1629/// | towards $\infty$ | [`CeilingModPowerOf2`](traits::CeilingModPowerOf2) | [`CeilingModPowerOf2Assign`](traits::CeilingModPowerOf2Assign) |
1630/// | towards $\infty$ | [`NegModPowerOf2`](traits::NegModPowerOf2) | [`NegModPowerOf2Assign`](traits::NegModPowerOf2Assign) |
1631///
1632/// [`CeilingModPowerOf2`](traits::CeilingModPowerOf2) and
1633/// [`NegModPowerOf2`](traits::NegModPowerOf2) are similar. The difference is that
1634/// [`CeilingModPowerOf2`](traits::CeilingModPowerOf2) returns a remainder less than or equal to 0,
1635/// so that the usual relation $x = q2^k + r$ is satisfied, while
1636/// [`NegModPowerOf2`](traits::NegModPowerOf2) returns a remainder greater than or equal to zero.
1637/// This allows the remainder to have an unsigned type, but modifies the relation to $x = q2^k - r$.
1638///
1639/// # mod_power_of_2
1640/// ```
1641/// use malachite_base::num::arithmetic::traits::ModPowerOf2;
1642///
1643/// // 1 * 2^8 + 4 = 260
1644/// assert_eq!(260u16.mod_power_of_2(8), 4);
1645///
1646/// // 100 * 2^4 + 11 = 1611
1647/// assert_eq!(1611u32.mod_power_of_2(4), 11);
1648///
1649/// // 1 * 2^8 + 4 = 260
1650/// assert_eq!(260i16.mod_power_of_2(8), 4);
1651///
1652/// // -101 * 2^4 + 5 = -1611
1653/// assert_eq!((-1611i32).mod_power_of_2(4), 5);
1654/// ```
1655///
1656/// # mod_power_of_2_assign
1657/// ```
1658/// use malachite_base::num::arithmetic::traits::ModPowerOf2Assign;
1659///
1660/// // 1 * 2^8 + 4 = 260
1661/// let mut x = 260u16;
1662/// x.mod_power_of_2_assign(8);
1663/// assert_eq!(x, 4);
1664///
1665/// // 100 * 2^4 + 11 = 1611
1666/// let mut x = 1611u32;
1667/// x.mod_power_of_2_assign(4);
1668/// assert_eq!(x, 11);
1669///
1670/// // 1 * 2^8 + 4 = 260
1671/// let mut x = 260i16;
1672/// x.mod_power_of_2_assign(8);
1673/// assert_eq!(x, 4);
1674///
1675/// // -101 * 2^4 + 5 = -1611
1676/// let mut x = -1611i32;
1677/// x.mod_power_of_2_assign(4);
1678/// assert_eq!(x, 5);
1679/// ```
1680///
1681/// # rem_power_of_2
1682/// ```
1683/// use malachite_base::num::arithmetic::traits::RemPowerOf2;
1684///
1685/// // 1 * 2^8 + 4 = 260
1686/// assert_eq!(260u16.rem_power_of_2(8), 4);
1687///
1688/// // 100 * 2^4 + 11 = 1611
1689/// assert_eq!(1611u32.rem_power_of_2(4), 11);
1690///
1691/// // 1 * 2^8 + 4 = 260
1692/// assert_eq!(260i16.rem_power_of_2(8), 4);
1693///
1694/// // -100 * 2^4 + -11 = -1611
1695/// assert_eq!((-1611i32).rem_power_of_2(4), -11);
1696/// ```
1697///
1698/// # rem_power_of_2_assign
1699/// ```
1700/// use malachite_base::num::arithmetic::traits::RemPowerOf2Assign;
1701///
1702/// // 1 * 2^8 + 4 = 260
1703/// let mut x = 260u16;
1704/// x.rem_power_of_2_assign(8);
1705/// assert_eq!(x, 4);
1706///
1707/// // 100 * 2^4 + 11 = 1611
1708/// let mut x = 1611u32;
1709/// x.rem_power_of_2_assign(4);
1710/// assert_eq!(x, 11);
1711///
1712/// // 1 * 2^8 + 4 = 260
1713/// let mut x = 260i16;
1714/// x.rem_power_of_2_assign(8);
1715/// assert_eq!(x, 4);
1716///
1717/// // -100 * 2^4 + -11 = -1611
1718/// let mut x = -1611i32;
1719/// x.rem_power_of_2_assign(4);
1720/// assert_eq!(x, -11);
1721/// ```
1722///
1723/// # neg_mod_power_of_2
1724/// ```
1725/// use malachite_base::num::arithmetic::traits::NegModPowerOf2;
1726///
1727/// // 2 * 2^8 - 252 = 260
1728/// assert_eq!(260u16.neg_mod_power_of_2(8), 252);
1729///
1730/// // 101 * 2^4 - 5 = 1611
1731/// assert_eq!(1611u32.neg_mod_power_of_2(4), 5);
1732/// ```
1733///
1734/// # neg_mod_power_of_2_assign
1735/// ```
1736/// use malachite_base::num::arithmetic::traits::NegModPowerOf2Assign;
1737///
1738/// // 2 * 2^8 - 252 = 260
1739/// let mut x = 260u16;
1740/// x.neg_mod_power_of_2_assign(8);
1741/// assert_eq!(x, 252);
1742///
1743/// // 101 * 2^4 - 5 = 1611
1744/// let mut x = 1611u32;
1745/// x.neg_mod_power_of_2_assign(4);
1746/// assert_eq!(x, 5);
1747/// ```
1748///
1749/// # ceiling_mod_power_of_2
1750/// ```
1751/// use malachite_base::num::arithmetic::traits::CeilingModPowerOf2;
1752///
1753/// // 2 * 2^8 + -252 = 260
1754/// assert_eq!(260i16.ceiling_mod_power_of_2(8), -252);
1755///
1756/// // -100 * 2^4 + -11 = -1611
1757/// assert_eq!((-1611i32).ceiling_mod_power_of_2(4), -11);
1758/// ```
1759///
1760/// # ceiling_mod_power_of_2_assign
1761/// ```
1762/// use malachite_base::num::arithmetic::traits::CeilingModPowerOf2Assign;
1763///
1764/// // 2 * 2^8 + -252 = 260
1765/// let mut x = 260i16;
1766/// x.ceiling_mod_power_of_2_assign(8);
1767/// assert_eq!(x, -252);
1768///
1769/// // -100 * 2^4 + -11 = -1611
1770/// let mut x = -1611i32;
1771/// x.ceiling_mod_power_of_2_assign(4);
1772/// assert_eq!(x, -11);
1773/// ```
1774pub mod mod_power_of_2;
1775/// [`ModPowerOf2Add`](traits::ModPowerOf2Add) and
1776/// [`ModPowerOf2AddAssign`](traits::ModPowerOf2AddAssign), traits for adding two numbers modulo
1777/// $2^k$.
1778///
1779/// # mod_power_of_2_add
1780/// ```
1781/// use malachite_base::num::arithmetic::traits::ModPowerOf2Add;
1782///
1783/// assert_eq!(0u8.mod_power_of_2_add(2, 5), 2);
1784/// assert_eq!(10u32.mod_power_of_2_add(14, 4), 8);
1785/// ```
1786///
1787/// # mod_power_of_2_add_assign
1788/// ```
1789/// use malachite_base::num::arithmetic::traits::ModPowerOf2AddAssign;
1790///
1791/// let mut n = 0u8;
1792/// n.mod_power_of_2_add_assign(2, 5);
1793/// assert_eq!(n, 2);
1794///
1795/// let mut n = 10u32;
1796/// n.mod_power_of_2_add_assign(14, 4);
1797/// assert_eq!(n, 8);
1798/// ```
1799pub mod mod_power_of_2_add;
1800/// [`ModPowerOf2Inverse`](traits::ModPowerOf2Inverse), a trait for finding the multiplicative
1801/// inverse of a number modulo $2^k$.
1802///
1803/// # mod_inverse
1804/// ```
1805/// use malachite_base::num::arithmetic::traits::ModPowerOf2Inverse;
1806///
1807/// assert_eq!(7u8.mod_power_of_2_inverse(4), Some(7));
1808/// assert_eq!(8u8.mod_power_of_2_inverse(4), None);
1809/// assert_eq!(123u32.mod_power_of_2_inverse(7), Some(51));
1810/// ```
1811pub mod mod_power_of_2_inverse;
1812/// [`ModPowerOf2IsReduced`](traits::ModPowerOf2IsReduced), a trait for checking whether a number is
1813/// reduced modulo $2^k$.
1814///
1815/// # mod_power_of_2_is_reduced
1816/// ```
1817/// use malachite_base::num::arithmetic::traits::ModPowerOf2IsReduced;
1818///
1819/// assert_eq!(0u8.mod_power_of_2_is_reduced(5), true);
1820/// assert_eq!(100u64.mod_power_of_2_is_reduced(5), false);
1821/// assert_eq!(100u16.mod_power_of_2_is_reduced(8), true);
1822/// ```
1823pub mod mod_power_of_2_is_reduced;
1824/// [`ModPowerOf2Mul`](traits::ModPowerOf2Mul) and
1825/// [`ModPowerOf2MulAssign`](traits::ModPowerOf2MulAssign), traits for multiplying two numbers
1826/// modulo $2^k$.
1827///
1828/// # mod_power_of_2_mul
1829/// ```
1830/// use malachite_base::num::arithmetic::traits::ModPowerOf2Mul;
1831///
1832/// assert_eq!(3u8.mod_power_of_2_mul(2, 5), 6);
1833/// assert_eq!(10u32.mod_power_of_2_mul(14, 4), 12);
1834/// ```
1835///
1836/// # mod_power_of_2_mul_assign
1837/// ```
1838/// use malachite_base::num::arithmetic::traits::ModPowerOf2MulAssign;
1839///
1840/// let mut n = 3u8;
1841/// n.mod_power_of_2_mul_assign(2, 5);
1842/// assert_eq!(n, 6);
1843///
1844/// let mut n = 10u32;
1845/// n.mod_power_of_2_mul_assign(14, 4);
1846/// assert_eq!(n, 12);
1847/// ```
1848pub mod mod_power_of_2_mul;
1849/// [`ModPowerOf2Neg`](traits::ModPowerOf2Neg) and
1850/// [`ModPowerOf2NegAssign`](traits::ModPowerOf2NegAssign), traits for negating a number modulo
1851/// $2^k$.
1852///
1853/// # mod_power_of_2_neg
1854/// ```
1855/// use malachite_base::num::arithmetic::traits::ModPowerOf2Neg;
1856///
1857/// assert_eq!(0u8.mod_power_of_2_neg(5), 0);
1858/// assert_eq!(10u32.mod_power_of_2_neg(4), 6);
1859/// assert_eq!(100u16.mod_power_of_2_neg(8), 156);
1860/// ```
1861///
1862/// # mod_power_of_2_neg_assign
1863/// ```
1864/// use malachite_base::num::arithmetic::traits::ModPowerOf2NegAssign;
1865///
1866/// let mut n = 0u8;
1867/// n.mod_power_of_2_neg_assign(5);
1868/// assert_eq!(n, 0);
1869///
1870/// let mut n = 10u32;
1871/// n.mod_power_of_2_neg_assign(4);
1872/// assert_eq!(n, 6);
1873///
1874/// let mut n = 100u16;
1875/// n.mod_power_of_2_neg_assign(8);
1876/// assert_eq!(n, 156);
1877/// ```
1878pub mod mod_power_of_2_neg;
1879/// [`ModPowerOf2Pow`](traits::ModPowerOf2Pow) and
1880/// [`ModPowerOf2PowAssign`](traits::ModPowerOf2PowAssign), traits for raising a number to a power
1881/// modulo $2^k$.
1882///
1883/// # mod_power_of_2_pow
1884/// ```
1885/// use malachite_base::num::arithmetic::traits::ModPowerOf2Pow;
1886///
1887/// assert_eq!(5u8.mod_power_of_2_pow(13, 3), 5);
1888/// assert_eq!(7u32.mod_power_of_2_pow(1000, 6), 1);
1889/// ```
1890///
1891/// # mod_power_of_2_pow_assign
1892/// ```
1893/// use malachite_base::num::arithmetic::traits::ModPowerOf2PowAssign;
1894///
1895/// let mut n = 5u8;
1896/// n.mod_power_of_2_pow_assign(13, 3);
1897/// assert_eq!(n, 5);
1898///
1899/// let mut n = 7u32;
1900/// n.mod_power_of_2_pow_assign(1000, 6);
1901/// assert_eq!(n, 1);
1902/// ```
1903pub mod mod_power_of_2_pow;
1904/// [`ModPowerOf2Shl`](traits::ModPowerOf2Shl) and
1905/// [`ModPowerOf2ShlAssign`](traits::ModPowerOf2ShlAssign), traits for left-shifting a number modulo
1906/// $2^k$.
1907///
1908/// # mod_power_of_2_shl
1909/// ```
1910/// use malachite_base::num::arithmetic::traits::ModPowerOf2Shl;
1911///
1912/// assert_eq!(12u32.mod_power_of_2_shl(2u8, 5), 16);
1913/// assert_eq!(10u8.mod_power_of_2_shl(100u64, 4), 0);
1914///
1915/// assert_eq!(12u32.mod_power_of_2_shl(2i8, 5), 16);
1916/// assert_eq!(10u8.mod_power_of_2_shl(-2i64, 4), 2);
1917/// ```
1918///
1919/// # mod_power_of_2_shl_assign
1920/// ```
1921/// use malachite_base::num::arithmetic::traits::ModPowerOf2ShlAssign;
1922///
1923/// let mut n = 12u32;
1924/// n.mod_power_of_2_shl_assign(2u8, 5);
1925/// assert_eq!(n, 16);
1926///
1927/// let mut n = 10u8;
1928/// n.mod_power_of_2_shl_assign(100u64, 4);
1929/// assert_eq!(n, 0);
1930///
1931/// let mut n = 12u32;
1932/// n.mod_power_of_2_shl_assign(2i8, 5);
1933/// assert_eq!(n, 16);
1934///
1935/// let mut n = 10u8;
1936/// n.mod_power_of_2_shl_assign(-2i64, 4);
1937/// assert_eq!(n, 2);
1938/// ```
1939pub mod mod_power_of_2_shl;
1940/// [`ModPowerOf2Shr`](traits::ModPowerOf2Shr) and
1941/// [`ModPowerOf2ShrAssign`](traits::ModPowerOf2ShrAssign), traits for right-shifting a number
1942/// modulo $2^k$.
1943///
1944/// # mod_power_of_2_shr
1945/// ```
1946/// use malachite_base::num::arithmetic::traits::ModPowerOf2Shr;
1947///
1948/// assert_eq!(10u8.mod_power_of_2_shr(2i64, 4), 2);
1949/// assert_eq!(12u32.mod_power_of_2_shr(-2i8, 5), 16);
1950/// ```
1951///
1952/// # mod_power_of_2_shr_assign
1953/// ```
1954/// use malachite_base::num::arithmetic::traits::ModPowerOf2ShrAssign;
1955///
1956/// let mut n = 10u8;
1957/// n.mod_power_of_2_shr_assign(2i64, 4);
1958/// assert_eq!(n, 2);
1959///
1960/// let mut n = 12u32;
1961/// n.mod_power_of_2_shr_assign(-2i8, 5);
1962/// assert_eq!(n, 16);
1963/// ```
1964pub mod mod_power_of_2_shr;
1965/// [`ModPowerOf2Square`](traits::ModPowerOf2Square) and
1966/// [`ModPowerOf2SquareAssign`](traits::ModPowerOf2SquareAssign), traits for squaring a number
1967/// modulo $2^k$.
1968///
1969/// # mod_power_of_2_square
1970/// ```
1971/// use malachite_base::num::arithmetic::traits::ModPowerOf2Square;
1972///
1973/// assert_eq!(5u8.mod_power_of_2_square(3), 1);
1974/// assert_eq!(100u32.mod_power_of_2_square(8), 16);
1975/// ```
1976///
1977/// # mod_power_of_2_square_assign
1978/// ```
1979/// use malachite_base::num::arithmetic::traits::ModPowerOf2SquareAssign;
1980///
1981/// let mut n = 5u8;
1982/// n.mod_power_of_2_square_assign(3);
1983/// assert_eq!(n, 1);
1984///
1985/// let mut n = 100u32;
1986/// n.mod_power_of_2_square_assign(8);
1987/// assert_eq!(n, 16);
1988/// ```
1989pub mod mod_power_of_2_square;
1990/// [`ModPowerOf2Sub`](traits::ModPowerOf2Sub) and
1991/// [`ModPowerOf2SubAssign`](traits::ModPowerOf2SubAssign), traits for subtracting one number by
1992/// another modulo $2^k$.
1993///
1994/// # mod_power_of_2_sub
1995/// ```
1996/// use malachite_base::num::arithmetic::traits::ModPowerOf2Sub;
1997///
1998/// assert_eq!(5u8.mod_power_of_2_sub(2, 5), 3);
1999/// assert_eq!(10u32.mod_power_of_2_sub(14, 4), 12);
2000/// ```
2001///
2002/// # mod_power_of_2_sub_assign
2003/// ```
2004/// use malachite_base::num::arithmetic::traits::ModPowerOf2SubAssign;
2005///
2006/// let mut n = 5u8;
2007/// n.mod_power_of_2_sub_assign(2, 5);
2008/// assert_eq!(n, 3);
2009///
2010/// let mut n = 10u32;
2011/// n.mod_power_of_2_sub_assign(14, 4);
2012/// assert_eq!(n, 12);
2013/// ```
2014pub mod mod_power_of_2_sub;
2015/// [`ModShl`](traits::ModShl) and [`ModShlAssign`](traits::ModShlAssign), traits for left-shifting
2016/// a number modulo another number.
2017///
2018/// # mod_shl
2019/// ```
2020/// use malachite_base::num::arithmetic::traits::ModShl;
2021///
2022/// assert_eq!(8u32.mod_shl(2u8, 10), 2);
2023/// assert_eq!(10u8.mod_shl(100u64, 17), 7);
2024///
2025/// assert_eq!(8u32.mod_shl(2i8, 10), 2);
2026/// assert_eq!(10u8.mod_shl(-2i64, 15), 2);
2027/// ```
2028///
2029/// # mod_shl_assign
2030/// ```
2031/// use malachite_base::num::arithmetic::traits::ModShlAssign;
2032///
2033/// let mut n = 8u32;
2034/// n.mod_shl_assign(2u8, 10);
2035/// assert_eq!(n, 2);
2036///
2037/// let mut n = 10u8;
2038/// n.mod_shl_assign(100u64, 17);
2039/// assert_eq!(n, 7);
2040///
2041/// let mut n = 8u32;
2042/// n.mod_shl_assign(2i8, 10);
2043/// assert_eq!(n, 2);
2044///
2045/// let mut n = 10u8;
2046/// n.mod_shl_assign(-2i64, 15);
2047/// assert_eq!(n, 2);
2048/// ```
2049pub mod mod_shl;
2050/// [`ModShr`](traits::ModShr) and [`ModShrAssign`](traits::ModShrAssign), traits for right-shifting
2051/// a number modulo another number.
2052///
2053/// # mod_shr
2054/// ```
2055/// use malachite_base::num::arithmetic::traits::ModShr;
2056///
2057/// assert_eq!(10u8.mod_shr(2i64, 15), 2);
2058/// assert_eq!(8u32.mod_shr(-2i8, 10), 2);
2059/// ```
2060///
2061/// # mod_shr_assign
2062/// ```
2063/// use malachite_base::num::arithmetic::traits::ModShrAssign;
2064///
2065/// let mut n = 10u8;
2066/// n.mod_shr_assign(2i64, 15);
2067/// assert_eq!(n, 2);
2068///
2069/// let mut n = 8u32;
2070/// n.mod_shr_assign(-2i8, 10);
2071/// assert_eq!(n, 2);
2072/// ```
2073pub mod mod_shr;
2074/// Traits for squaring a number modulo another number.
2075///
2076/// The traits are [`ModSquare`](traits::ModSquare), [`ModSquareAssign`](traits::ModSquareAssign),
2077/// and [`ModSquarePrecomputed`](traits::ModSquarePrecomputed).
2078/// [`ModSquarePrecomputed`](traits::ModSquarePrecomputed) is useful when having to make several
2079/// squarings modulo the same modulus.
2080///
2081/// # mod_square
2082/// ```
2083/// use malachite_base::num::arithmetic::traits::ModSquare;
2084///
2085/// assert_eq!(2u8.mod_square(10), 4);
2086/// assert_eq!(100u32.mod_square(497), 60);
2087/// ```
2088///
2089/// # mod_square_assign
2090/// ```
2091/// use malachite_base::num::arithmetic::traits::ModSquareAssign;
2092///
2093/// let mut n = 2u8;
2094/// n.mod_square_assign(10);
2095/// assert_eq!(n, 4);
2096///
2097/// let mut n = 100u32;
2098/// n.mod_square_assign(497);
2099/// assert_eq!(n, 60);
2100/// ```
2101///
2102/// # mod_square_precomputed
2103/// ```
2104/// use malachite_base::num::arithmetic::traits::{ModPowPrecomputed, ModSquarePrecomputed};
2105///
2106/// let data = u16::precompute_mod_pow_data(&497);
2107/// assert_eq!(100u16.mod_square_precomputed(497, &data), 60);
2108/// assert_eq!(200u16.mod_square_precomputed(497, &data), 240);
2109/// assert_eq!(300u16.mod_square_precomputed(497, &data), 43);
2110/// ```
2111///
2112/// # mod_square_precomputed_assign
2113/// ```
2114/// use malachite_base::num::arithmetic::traits::{ModPowPrecomputed, ModSquarePrecomputedAssign};
2115///
2116/// let data = u32::precompute_mod_pow_data(&497);
2117///
2118/// let mut x = 100u32;
2119/// x.mod_square_precomputed_assign(497, &data);
2120/// assert_eq!(x, 60);
2121///
2122/// let mut x = 200u32;
2123/// x.mod_square_precomputed_assign(497, &data);
2124/// assert_eq!(x, 240);
2125///
2126/// let mut x = 300u32;
2127/// x.mod_square_precomputed_assign(497, &data);
2128/// assert_eq!(x, 43);
2129/// ```
2130pub mod mod_square;
2131/// [`ModSub`](traits::ModSub) and [`ModSubAssign`](traits::ModSubAssign), traits for subtracting
2132/// two numbers modulo another number.
2133///
2134/// # mod_sub
2135/// ```
2136/// use malachite_base::num::arithmetic::traits::ModSub;
2137///
2138/// assert_eq!(4u8.mod_sub(3, 5), 1);
2139/// assert_eq!(7u32.mod_sub(9, 10), 8);
2140/// ```
2141///
2142/// # mod_sub_assign
2143/// ```
2144/// use malachite_base::num::arithmetic::traits::ModSubAssign;
2145///
2146/// let mut n = 4u8;
2147/// n.mod_sub_assign(3, 5);
2148/// assert_eq!(n, 1);
2149///
2150/// let mut n = 7u32;
2151/// n.mod_sub_assign(9, 10);
2152/// assert_eq!(n, 8);
2153/// ```
2154pub mod mod_sub;
2155/// [`NegAssign`](traits::NegAssign), a trait for negating a number in place.
2156///
2157/// # neg_assign
2158/// ```
2159/// use malachite_base::num::arithmetic::traits::NegAssign;
2160///
2161/// let mut x = 0i8;
2162/// x.neg_assign();
2163/// assert_eq!(x, 0i8);
2164///
2165/// let mut x = 100i64;
2166/// x.neg_assign();
2167/// assert_eq!(x, -100i64);
2168///
2169/// let mut x = -100i64;
2170/// x.neg_assign();
2171/// assert_eq!(x, 100i64);
2172///
2173/// let mut x = 1.2f32;
2174/// x.neg_assign();
2175/// assert_eq!(x, -1.2f32);
2176/// ```
2177pub mod neg;
2178/// [`NextPowerOf2`](traits::NextPowerOf2) and [`NextPowerOf2Assign`](traits::NextPowerOf2Assign),
2179/// traits for getting the next-highest power of 2.
2180///
2181/// # next_power_of_2
2182/// ```
2183/// use malachite_base::num::arithmetic::traits::NextPowerOf2;
2184///
2185/// assert_eq!(100.0f32.next_power_of_2(), 128.0);
2186/// assert_eq!(0.01f32.next_power_of_2(), 0.015625);
2187/// ```
2188///
2189/// # next_power_of_2_assign
2190/// ```
2191/// use malachite_base::num::arithmetic::traits::NextPowerOf2Assign;
2192///
2193/// let mut x = 0u8;
2194/// x.next_power_of_2_assign();
2195/// assert_eq!(x, 1);
2196///
2197/// let mut x = 4u16;
2198/// x.next_power_of_2_assign();
2199/// assert_eq!(x, 4);
2200///
2201/// let mut x = 10u32;
2202/// x.next_power_of_2_assign();
2203/// assert_eq!(x, 16);
2204///
2205/// let mut x = (1u64 << 40) - 5;
2206/// x.next_power_of_2_assign();
2207/// assert_eq!(x, 1 << 40);
2208///
2209/// let mut x = 100.0f32;
2210/// x.next_power_of_2_assign();
2211/// assert_eq!(x, 128.0);
2212///
2213/// let mut x = 0.01f32;
2214/// x.next_power_of_2_assign();
2215/// assert_eq!(x, 0.015625);
2216/// ```
2217pub mod next_power_of_2;
2218/// [`OverflowingAbs`](traits::OverflowingAbs) and
2219/// [`OverflowingAbsAssign`](traits::OverflowingAbsAssign), traits for taking the absolute value of
2220/// a number and returning a boolean indicating whether an overflow occurred.
2221///
2222/// # overflowing_abs_assign
2223/// ```
2224/// use malachite_base::num::arithmetic::traits::OverflowingAbsAssign;
2225///
2226/// let mut x = 0i8;
2227/// assert_eq!(x.overflowing_abs_assign(), false);
2228/// assert_eq!(x, 0);
2229///
2230/// let mut x = 100i64;
2231/// assert_eq!(x.overflowing_abs_assign(), false);
2232/// assert_eq!(x, 100);
2233///
2234/// let mut x = -100i64;
2235/// assert_eq!(x.overflowing_abs_assign(), false);
2236/// assert_eq!(x, 100);
2237///
2238/// let mut x = -128i8;
2239/// assert_eq!(x.overflowing_abs_assign(), true);
2240/// assert_eq!(x, -128);
2241/// ```
2242pub mod overflowing_abs;
2243/// [`OverflowingAdd`](traits::OverflowingAdd) and
2244/// [`OverflowingAddAssign`](traits::OverflowingAddAssign), traits for adding two numbers and
2245/// returning a boolean indicating whether an overflow occurred.
2246///
2247/// # overflowing_add_assign
2248/// ```
2249/// use malachite_base::num::arithmetic::traits::OverflowingAddAssign;
2250///
2251/// let mut x = 123u16;
2252/// assert_eq!(x.overflowing_add_assign(456), false);
2253/// assert_eq!(x, 579);
2254///
2255/// let mut x = 123u8;
2256/// assert_eq!(x.overflowing_add_assign(200), true);
2257/// assert_eq!(x, 67);
2258/// ```
2259pub mod overflowing_add;
2260/// [`OverflowingAddMul`](traits::OverflowingAddMul) and
2261/// [`OverflowingAddMulAssign`](traits::OverflowingAddMulAssign), traits for adding the product of
2262/// two other numbers to a number and returning a boolean indicating whether an overflow occurred.
2263///
2264/// # overflowing_add_mul
2265/// ```
2266/// use malachite_base::num::arithmetic::traits::OverflowingAddMul;
2267///
2268/// assert_eq!(2u8.overflowing_add_mul(3, 7), (23, false));
2269/// assert_eq!(2u8.overflowing_add_mul(20, 20), (146, true));
2270///
2271/// assert_eq!(127i8.overflowing_add_mul(-2, 100), (-73, false));
2272/// assert_eq!((-127i8).overflowing_add_mul(-2, 100), (-71, true));
2273/// ```
2274///
2275/// # overflowing_add_mul_assign
2276/// ```
2277/// use malachite_base::num::arithmetic::traits::OverflowingAddMulAssign;
2278///
2279/// let mut x = 2u8;
2280/// assert_eq!(x.overflowing_add_mul_assign(3, 7), false);
2281/// assert_eq!(x, 23);
2282///
2283/// let mut x = 2u8;
2284/// assert_eq!(x.overflowing_add_mul_assign(20, 20), true);
2285/// assert_eq!(x, 146);
2286///
2287/// let mut x = 127i8;
2288/// assert_eq!(x.overflowing_add_mul_assign(-2, 100), false);
2289/// assert_eq!(x, -73);
2290///
2291/// let mut x = -127i8;
2292/// assert_eq!(x.overflowing_add_mul_assign(-2, 100), true);
2293/// assert_eq!(x, -71);
2294/// ```
2295pub mod overflowing_add_mul;
2296/// [`OverflowingDiv`](traits::OverflowingDiv) and
2297/// [`OverflowingDivAssign`](traits::OverflowingDivAssign), traits for dividing two numbers and
2298/// returning a boolean indicating whether an overflow occurred.
2299///
2300/// # overflowing_div_assign
2301/// ```
2302/// use malachite_base::num::arithmetic::traits::OverflowingDivAssign;
2303///
2304/// let mut x = 100u16;
2305/// assert_eq!(x.overflowing_div_assign(3), false);
2306/// assert_eq!(x, 33);
2307///
2308/// let mut x = -128i8;
2309/// assert_eq!(x.overflowing_div_assign(-1), true);
2310/// assert_eq!(x, -128);
2311/// ```
2312pub mod overflowing_div;
2313/// [`OverflowingMul`](traits::OverflowingMul) and
2314/// [`OverflowingMulAssign`](traits::OverflowingMulAssign), traits for multiplying two numbers and
2315/// returning a boolean indicating whether an overflow occurred.
2316///
2317/// # overflowing_mul_assign
2318/// ```
2319/// use malachite_base::num::arithmetic::traits::OverflowingMulAssign;
2320///
2321/// let mut x = 123u16;
2322/// assert_eq!(x.overflowing_mul_assign(456), false);
2323/// assert_eq!(x, 56088);
2324///
2325/// let mut x = 123u8;
2326/// assert_eq!(x.overflowing_mul_assign(200), true);
2327/// assert_eq!(x, 24);
2328/// ```
2329pub mod overflowing_mul;
2330/// [`OverflowingNeg`](traits::OverflowingNeg) and
2331/// [`OverflowingNegAssign`](traits::OverflowingNegAssign), traits for negating a number and
2332/// returning a boolean indicating whether an overflow occurred.
2333///
2334/// # overflowing_neg_assign
2335/// ```
2336/// use malachite_base::num::arithmetic::traits::OverflowingNegAssign;
2337///
2338/// let mut x = 0i8;
2339/// assert_eq!(x.overflowing_neg_assign(), false);
2340/// assert_eq!(x, 0);
2341///
2342/// let mut x = 100u64;
2343/// assert_eq!(x.overflowing_neg_assign(), true);
2344/// assert_eq!(x, 18446744073709551516);
2345///
2346/// let mut x = -100i64;
2347/// assert_eq!(x.overflowing_neg_assign(), false);
2348/// assert_eq!(x, 100);
2349///
2350/// let mut x = -128i8;
2351/// assert_eq!(x.overflowing_neg_assign(), true);
2352/// assert_eq!(x, -128);
2353/// ```
2354pub mod overflowing_neg;
2355/// [`OverflowingPow`](traits::OverflowingPow) and
2356/// [`OverflowingPowAssign`](traits::OverflowingPowAssign), traits for raising a number to a power
2357/// and returning a boolean indicating whether an overflow occurred.
2358///
2359/// # overflowing_pow_assign
2360/// ```
2361/// use malachite_base::num::arithmetic::traits::OverflowingPowAssign;
2362///
2363/// let mut x = 3u8;
2364/// assert_eq!(x.overflowing_pow_assign(3), false);
2365/// assert_eq!(x, 27);
2366///
2367/// let mut x = -10i32;
2368/// assert_eq!(x.overflowing_pow_assign(9), false);
2369/// assert_eq!(x, -1000000000);
2370///
2371/// let mut x = -10i16;
2372/// assert_eq!(x.overflowing_pow_assign(9), true);
2373/// assert_eq!(x, 13824);
2374/// ```
2375pub mod overflowing_pow;
2376/// [`OverflowingSquare`](traits::OverflowingSquare) and
2377/// [`OverflowingSquareAssign`](traits::OverflowingSquareAssign), traits for squaring a number and
2378/// returning a boolean indicating whether an overflow occurred.
2379///
2380/// # overflowing_square_assign
2381/// ```
2382/// use malachite_base::num::arithmetic::traits::OverflowingSquareAssign;
2383///
2384/// let mut x = 3u8;
2385/// assert_eq!(x.overflowing_square_assign(), false);
2386/// assert_eq!(x, 9);
2387///
2388/// let mut x = -1000i32;
2389/// assert_eq!(x.overflowing_square_assign(), false);
2390/// assert_eq!(x, 1000000);
2391///
2392/// let mut x = 1000u16;
2393/// assert_eq!(x.overflowing_square_assign(), true);
2394/// assert_eq!(x, 16960);
2395/// ```
2396pub mod overflowing_square;
2397/// [`OverflowingSub`](traits::OverflowingSub) and
2398/// [`OverflowingSubAssign`](traits::OverflowingSubAssign), traits for subtracting two numbers and
2399/// returning a boolean indicating whether an overflow occurred.
2400///
2401/// # overflowing_sub
2402/// ```
2403/// use malachite_base::num::arithmetic::traits::OverflowingSquare;
2404///
2405/// assert_eq!(3u8.overflowing_square(), (9, false));
2406/// assert_eq!((-1000i32).overflowing_square(), (1000000, false));
2407/// assert_eq!(1000u16.overflowing_square(), (16960, true));
2408/// ```
2409///
2410/// # overflowing_sub_assign
2411/// ```
2412/// use malachite_base::num::arithmetic::traits::OverflowingSubAssign;
2413///
2414/// let mut x = 456u16;
2415/// assert_eq!(x.overflowing_sub_assign(123), false);
2416/// assert_eq!(x, 333);
2417///
2418/// let mut x = 123u16;
2419/// assert_eq!(x.overflowing_sub_assign(456), true);
2420/// assert_eq!(x, 65203);
2421/// ```
2422pub mod overflowing_sub;
2423/// [`OverflowingSubMul`](traits::OverflowingSubMul) and
2424/// [`OverflowingSubMulAssign`](traits::OverflowingSubMulAssign), traits for subtracting the product
2425/// of two other numbers from a number and returning a boolean indicating whether an overflow
2426/// occurred.
2427///
2428/// # overflowing_sub_mul
2429/// ```
2430/// use malachite_base::num::arithmetic::traits::OverflowingSubMul;
2431///
2432/// assert_eq!(60u8.overflowing_sub_mul(5, 10), (10, false));
2433/// assert_eq!(2u8.overflowing_sub_mul(10, 5), (208, true));
2434///
2435/// assert_eq!(127i8.overflowing_sub_mul(2, 100), (-73, false));
2436/// assert_eq!((-127i8).overflowing_sub_mul(2, 100), (-71, true));
2437/// ```
2438///
2439/// # overflowing_sub_mul_assign
2440/// ```
2441/// use malachite_base::num::arithmetic::traits::OverflowingSubMulAssign;
2442///
2443/// let mut x = 60u8;
2444/// assert_eq!(x.overflowing_sub_mul_assign(5, 10), false);
2445/// assert_eq!(x, 10);
2446///
2447/// let mut x = 2u8;
2448/// assert_eq!(x.overflowing_sub_mul_assign(10, 5), true);
2449/// assert_eq!(x, 208);
2450///
2451/// let mut x = 127i8;
2452/// assert_eq!(x.overflowing_sub_mul_assign(2, 100), false);
2453/// assert_eq!(x, -73);
2454///
2455/// let mut x = -127i8;
2456/// assert_eq!(x.overflowing_sub_mul_assign(2, 100), true);
2457/// assert_eq!(x, -71);
2458/// ```
2459pub mod overflowing_sub_mul;
2460/// [`Parity`](traits::Parity), a trait for determining whether a number is even or odd.
2461///
2462/// # even
2463/// ```
2464/// use malachite_base::num::arithmetic::traits::Parity;
2465///
2466/// assert_eq!(0u8.even(), true);
2467/// assert_eq!((-5i16).even(), false);
2468/// assert_eq!(4u32.even(), true);
2469/// ```
2470///
2471/// # odd
2472/// ```
2473/// use malachite_base::num::arithmetic::traits::Parity;
2474///
2475/// assert_eq!(0u8.odd(), false);
2476/// assert_eq!((-5i16).odd(), true);
2477/// assert_eq!(4u32.odd(), false);
2478/// ```
2479pub mod parity;
2480/// [`Pow`](traits::Pow) and [`PowAssign`](traits::PowAssign), traits for raising a number to a
2481/// power.
2482///
2483/// # pow_assign
2484/// ```
2485/// use malachite_base::num::arithmetic::traits::PowAssign;
2486///
2487/// let mut x = 3u8;
2488/// x.pow_assign(3);
2489/// assert_eq!(x, 27);
2490///
2491/// let mut x = -10i32;
2492/// x.pow_assign(9);
2493/// assert_eq!(x, -1000000000);
2494///
2495/// let mut x = 2.0f32;
2496/// x.pow_assign(5);
2497/// assert_eq!(x, 32.0);
2498///
2499/// let mut x = 2.0f32;
2500/// x.pow_assign(5.0);
2501/// assert_eq!(x, 32.0);
2502/// ```
2503pub mod pow;
2504/// [`PowerOf2`](traits::PowerOf2), a trait for computing a power of 2.
2505///
2506/// # power_of_2
2507/// ```
2508/// use malachite_base::num::arithmetic::traits::PowerOf2;
2509///
2510/// assert_eq!(u16::power_of_2(0), 1);
2511/// assert_eq!(u8::power_of_2(3), 8);
2512/// assert_eq!(u64::power_of_2(40), 1 << 40);
2513///
2514/// assert_eq!(i16::power_of_2(0), 1);
2515/// assert_eq!(i8::power_of_2(3), 8);
2516/// assert_eq!(i64::power_of_2(40), 1 << 40);
2517///
2518/// assert_eq!(f32::power_of_2(0u64), 1.0);
2519/// assert_eq!(f32::power_of_2(3u64), 8.0);
2520/// assert_eq!(f32::power_of_2(-3i64), 0.125);
2521/// ```
2522pub mod power_of_2;
2523/// Traits for computing the primorial and the product of the first $n$ primes. There is a trait
2524/// whose implementations panic if the result cannot be represented, and a checked trait whose
2525/// implementations return `None` in that case: [`Primorial`](traits::Primorial) and
2526/// [`CheckedPrimorial`](traits::CheckedPrimorial).
2527///
2528/// # primorial
2529/// ```
2530/// use malachite_base::num::arithmetic::traits::Primorial;
2531///
2532/// assert_eq!(u8::primorial(0), 1);
2533/// assert_eq!(u8::primorial(1), 1);
2534/// assert_eq!(u8::primorial(2), 2);
2535/// assert_eq!(u8::primorial(3), 6);
2536/// assert_eq!(u8::primorial(4), 6);
2537/// assert_eq!(u8::primorial(5), 30);
2538/// assert_eq!(u32::primorial(20), 9699690);
2539/// ```
2540///
2541/// # product_of_first_n_primes
2542/// ```
2543/// use malachite_base::num::arithmetic::traits::Primorial;
2544///
2545/// assert_eq!(u8::product_of_first_n_primes(0), 1);
2546/// assert_eq!(u8::product_of_first_n_primes(1), 2);
2547/// assert_eq!(u8::product_of_first_n_primes(2), 6);
2548/// assert_eq!(u8::product_of_first_n_primes(3), 30);
2549/// assert_eq!(u8::product_of_first_n_primes(4), 210);
2550/// assert_eq!(u32::product_of_first_n_primes(9), 223092870);
2551/// ```
2552///
2553/// # checked_primorial
2554/// ```
2555/// use malachite_base::num::arithmetic::traits::CheckedPrimorial;
2556///
2557/// assert_eq!(u8::checked_primorial(0), Some(1));
2558/// assert_eq!(u8::checked_primorial(1), Some(1));
2559/// assert_eq!(u8::checked_primorial(2), Some(2));
2560/// assert_eq!(u8::checked_primorial(3), Some(6));
2561/// assert_eq!(u8::checked_primorial(4), Some(6));
2562/// assert_eq!(u8::checked_primorial(5), Some(30));
2563///
2564/// assert_eq!(u8::checked_primorial(11), None);
2565/// assert_eq!(u32::checked_primorial(20), Some(9699690));
2566/// assert_eq!(u32::checked_primorial(100), None);
2567/// ```
2568///
2569/// # checked_product_of_first_n_primes
2570/// ```
2571/// use malachite_base::num::arithmetic::traits::CheckedPrimorial;
2572///
2573/// assert_eq!(u8::checked_product_of_first_n_primes(0), Some(1));
2574/// assert_eq!(u8::checked_product_of_first_n_primes(1), Some(2));
2575/// assert_eq!(u8::checked_product_of_first_n_primes(2), Some(6));
2576/// assert_eq!(u8::checked_product_of_first_n_primes(3), Some(30));
2577/// assert_eq!(u8::checked_product_of_first_n_primes(4), Some(210));
2578/// assert_eq!(u32::checked_product_of_first_n_primes(9), Some(223092870));
2579///
2580/// assert_eq!(u8::checked_product_of_first_n_primes(5), None);
2581/// assert_eq!(u32::checked_product_of_first_n_primes(100), None);
2582/// ```
2583pub mod primorial;
2584/// [`Reciprocal`](traits::Reciprocal) and [`ReciprocalAssign`](traits::ReciprocalAssign), traits
2585/// for computing the reciprocal (multiplicative inverse) of a number.
2586///
2587/// # reciprocal
2588/// ```
2589/// use malachite_base::num::arithmetic::traits::Reciprocal;
2590///
2591/// assert_eq!(0.0f32.reciprocal(), f32::INFINITY);
2592/// assert_eq!(1.5f32.reciprocal(), 0.6666667);
2593/// ```
2594///
2595/// # reciprocal_assign
2596/// ```
2597/// use malachite_base::num::arithmetic::traits::ReciprocalAssign;
2598///
2599/// let mut x = 0.0f32;
2600/// x.reciprocal_assign();
2601/// assert_eq!(x, f32::INFINITY);
2602///
2603/// let mut x = 1.5f32;
2604/// x.reciprocal_assign();
2605/// assert_eq!(x, 0.6666667);
2606/// ```
2607pub mod reciprocal;
2608/// Traits for taking the $n$th root of a number.
2609///
2610/// The traits are [`FloorRoot`](traits::FloorRoot), [`FloorRootAssign`](traits::FloorRootAssign),
2611/// [`CeilingRoot`](traits::CeilingRoot), [`CeilingRootAssign`](traits::CeilingRootAssign),
2612/// [`CheckedRoot`](traits::CheckedRoot), [`RootRem`](traits::RootRem), and
2613/// [`RootAssignRem`](traits::RootAssignRem).
2614///
2615/// # floor_root
2616/// ```
2617/// use malachite_base::num::arithmetic::traits::FloorRoot;
2618///
2619/// assert_eq!(999u16.floor_root(3), 9);
2620/// assert_eq!(1000u16.floor_root(3), 10);
2621/// assert_eq!(1001u16.floor_root(3), 10);
2622/// assert_eq!(100000000000i64.floor_root(5), 158);
2623/// assert_eq!((-100000000000i64).floor_root(5), -159);
2624/// ```
2625///
2626/// # floor_root_assign
2627/// ```
2628/// use malachite_base::num::arithmetic::traits::FloorRootAssign;
2629///
2630/// let mut x = 999u16;
2631/// x.floor_root_assign(3);
2632/// assert_eq!(x, 9);
2633///
2634/// let mut x = 1000u16;
2635/// x.floor_root_assign(3);
2636/// assert_eq!(x, 10);
2637///
2638/// let mut x = 1001u16;
2639/// x.floor_root_assign(3);
2640/// assert_eq!(x, 10);
2641///
2642/// let mut x = 100000000000i64;
2643/// x.floor_root_assign(5);
2644/// assert_eq!(x, 158);
2645///
2646/// let mut x = -100000000000i64;
2647/// x.floor_root_assign(5);
2648/// assert_eq!(x, -159);
2649/// ```
2650///
2651/// # ceiling_root
2652/// ```
2653/// use malachite_base::num::arithmetic::traits::CeilingRoot;
2654///
2655/// assert_eq!(999u16.ceiling_root(3), 10);
2656/// assert_eq!(1000u16.ceiling_root(3), 10);
2657/// assert_eq!(1001u16.ceiling_root(3), 11);
2658/// assert_eq!(100000000000i64.ceiling_root(5), 159);
2659/// assert_eq!((-100000000000i64).ceiling_root(5), -158);
2660/// ```
2661///
2662/// # ceiling_root_assign
2663/// ```
2664/// use malachite_base::num::arithmetic::traits::CeilingRootAssign;
2665///
2666/// let mut x = 999u16;
2667/// x.ceiling_root_assign(3);
2668/// assert_eq!(x, 10);
2669///
2670/// let mut x = 1000u16;
2671/// x.ceiling_root_assign(3);
2672/// assert_eq!(x, 10);
2673///
2674/// let mut x = 1001u16;
2675/// x.ceiling_root_assign(3);
2676/// assert_eq!(x, 11);
2677///
2678/// let mut x = 100000000000i64;
2679/// x.ceiling_root_assign(5);
2680/// assert_eq!(x, 159);
2681///
2682/// let mut x = -100000000000i64;
2683/// x.ceiling_root_assign(5);
2684/// assert_eq!(x, -158);
2685/// ```
2686///
2687/// # checked_root
2688/// ```
2689/// use malachite_base::num::arithmetic::traits::CheckedRoot;
2690///
2691/// assert_eq!(999u16.checked_root(3), None);
2692/// assert_eq!(1000u16.checked_root(3), Some(10));
2693/// assert_eq!(1001u16.checked_root(3), None);
2694/// assert_eq!(100000000000i64.checked_root(5), None);
2695/// assert_eq!((-100000000000i64).checked_root(5), None);
2696/// assert_eq!(10000000000i64.checked_root(5), Some(100));
2697/// assert_eq!((-10000000000i64).checked_root(5), Some(-100));
2698/// ```
2699///
2700/// # root_rem
2701/// ```
2702/// use malachite_base::num::arithmetic::traits::RootRem;
2703///
2704/// assert_eq!(999u16.root_rem(3), (9, 270));
2705/// assert_eq!(1000u16.root_rem(3), (10, 0));
2706/// assert_eq!(1001u16.root_rem(3), (10, 1));
2707/// assert_eq!(100000000000u64.root_rem(5), (158, 1534195232));
2708/// ```
2709///
2710/// # root_assign_rem
2711/// ```
2712/// use malachite_base::num::arithmetic::traits::RootAssignRem;
2713///
2714/// let mut x = 999u16;
2715/// assert_eq!(x.root_assign_rem(3), 270);
2716/// assert_eq!(x, 9);
2717///
2718/// let mut x = 1000u16;
2719/// assert_eq!(x.root_assign_rem(3), 0);
2720/// assert_eq!(x, 10);
2721///
2722/// let mut x = 1001u16;
2723/// assert_eq!(x.root_assign_rem(3), 1);
2724/// assert_eq!(x, 10);
2725///
2726/// let mut x = 100000000000u64;
2727/// assert_eq!(x.root_assign_rem(5), 1534195232);
2728/// assert_eq!(x, 158);
2729/// ```
2730pub mod root;
2731/// [`RotateLeft`](traits::RotateLeft), [`RotateLeftAssign`](traits::RotateLeftAssign),
2732/// [`RotateRight`](traits::RotateRight), and [`RotateRightAssign`](traits::RotateRightAssign),
2733/// traits for rotating a number's bits.
2734///
2735/// # rotate_left_assign
2736/// ```
2737/// use malachite_base::num::arithmetic::traits::RotateLeftAssign;
2738///
2739/// let mut x: u32 = 0xabcd6789;
2740/// x.rotate_left_assign(4);
2741/// assert_eq!(x, 0xbcd6789a);
2742///
2743/// x = 0xabcd6789;
2744/// x.rotate_left_assign(32);
2745/// assert_eq!(x, 0xabcd6789);
2746///
2747/// x = 0xabcd6789;
2748/// x.rotate_left_assign(36);
2749/// assert_eq!(x, 0xbcd6789a);
2750/// ```
2751///
2752/// # rotate_right_assign
2753/// ```
2754/// use malachite_base::num::arithmetic::traits::RotateRightAssign;
2755///
2756/// let mut x: u32 = 0xabcd6789;
2757/// x.rotate_right_assign(4);
2758/// assert_eq!(x, 0x9abcd678);
2759///
2760/// x = 0xabcd6789;
2761/// x.rotate_right_assign(32);
2762/// assert_eq!(x, 0xabcd6789);
2763///
2764/// x = 0xabcd6789;
2765/// x.rotate_right_assign(36);
2766/// assert_eq!(x, 0x9abcd678);
2767/// ```
2768pub mod rotate;
2769/// [`RoundToMultiple`](traits::RoundToMultiple) and
2770/// [`RoundToMultipleAssign`](traits::RoundToMultipleAssign), traits for rounding a number to a
2771/// multiple of another number.
2772///
2773/// # round_to_multiple
2774/// ```
2775/// use malachite_base::num::arithmetic::traits::RoundToMultiple;
2776/// use malachite_base::rounding_modes::RoundingMode::*;
2777/// use std::cmp::Ordering::*;
2778///
2779/// assert_eq!(5u32.round_to_multiple(0, Down), (0, Less));
2780///
2781/// assert_eq!(10u8.round_to_multiple(4, Down), (8, Less));
2782/// assert_eq!(10u16.round_to_multiple(4, Up), (12, Greater));
2783/// assert_eq!(10u32.round_to_multiple(5, Exact), (10, Equal));
2784/// assert_eq!(10u64.round_to_multiple(3, Nearest), (9, Less));
2785/// assert_eq!(20u128.round_to_multiple(3, Nearest), (21, Greater));
2786/// assert_eq!(10usize.round_to_multiple(4, Nearest), (8, Less));
2787/// assert_eq!(14u8.round_to_multiple(4, Nearest), (16, Greater));
2788///
2789/// assert_eq!((-5i32).round_to_multiple(0, Down), (0, Greater));
2790///
2791/// assert_eq!((-10i8).round_to_multiple(4, Down), (-8, Greater));
2792/// assert_eq!((-10i16).round_to_multiple(4, Up), (-12, Less));
2793/// assert_eq!((-10i32).round_to_multiple(5, Exact), (-10, Equal));
2794/// assert_eq!((-10i64).round_to_multiple(3, Nearest), (-9, Greater));
2795/// assert_eq!((-20i128).round_to_multiple(3, Nearest), (-21, Less));
2796/// assert_eq!((-10isize).round_to_multiple(4, Nearest), (-8, Greater));
2797/// assert_eq!((-14i8).round_to_multiple(4, Nearest), (-16, Less));
2798///
2799/// assert_eq!((-10i16).round_to_multiple(-4, Down), (-8, Greater));
2800/// assert_eq!((-10i32).round_to_multiple(-4, Up), (-12, Less));
2801/// assert_eq!((-10i64).round_to_multiple(-5, Exact), (-10, Equal));
2802/// assert_eq!((-10i128).round_to_multiple(-3, Nearest), (-9, Greater));
2803/// assert_eq!((-20isize).round_to_multiple(-3, Nearest), (-21, Less));
2804/// assert_eq!((-10i8).round_to_multiple(-4, Nearest), (-8, Greater));
2805/// assert_eq!((-14i16).round_to_multiple(-4, Nearest), (-16, Less));
2806/// ```
2807///
2808/// # round_to_multiple_assign
2809/// ```
2810/// use malachite_base::num::arithmetic::traits::RoundToMultipleAssign;
2811/// use malachite_base::rounding_modes::RoundingMode::*;
2812/// use std::cmp::Ordering::*;
2813///
2814/// let mut x = 5u32;
2815/// assert_eq!(x.round_to_multiple_assign(0, Down), Less);
2816/// assert_eq!(x, 0);
2817///
2818/// let mut x = 10u8;
2819/// assert_eq!(x.round_to_multiple_assign(4, Down), Less);
2820/// assert_eq!(x, 8);
2821///
2822/// let mut x = 10u16;
2823/// assert_eq!(x.round_to_multiple_assign(4, Up), Greater);
2824/// assert_eq!(x, 12);
2825///
2826/// let mut x = 10u32;
2827/// assert_eq!(x.round_to_multiple_assign(5, Exact), Equal);
2828/// assert_eq!(x, 10);
2829///
2830/// let mut x = 10u64;
2831/// assert_eq!(x.round_to_multiple_assign(3, Nearest), Less);
2832/// assert_eq!(x, 9);
2833///
2834/// let mut x = 20u128;
2835/// assert_eq!(x.round_to_multiple_assign(3, Nearest), Greater);
2836/// assert_eq!(x, 21);
2837///
2838/// let mut x = 10usize;
2839/// assert_eq!(x.round_to_multiple_assign(4, Nearest), Less);
2840/// assert_eq!(x, 8);
2841///
2842/// let mut x = 14u8;
2843/// assert_eq!(x.round_to_multiple_assign(4, Nearest), Greater);
2844/// assert_eq!(x, 16);
2845///
2846/// let mut x = -5i32;
2847/// assert_eq!(x.round_to_multiple_assign(0, Down), Greater);
2848/// assert_eq!(x, 0);
2849///
2850/// let mut x = -10i8;
2851/// assert_eq!(x.round_to_multiple_assign(4, Down), Greater);
2852/// assert_eq!(x, -8);
2853///
2854/// let mut x = -10i16;
2855/// assert_eq!(x.round_to_multiple_assign(4, Up), Less);
2856/// assert_eq!(x, -12);
2857///
2858/// let mut x = -10i32;
2859/// assert_eq!(x.round_to_multiple_assign(5, Exact), Equal);
2860/// assert_eq!(x, -10);
2861///
2862/// let mut x = -10i64;
2863/// assert_eq!(x.round_to_multiple_assign(3, Nearest), Greater);
2864/// assert_eq!(x, -9);
2865///
2866/// let mut x = -20i128;
2867/// assert_eq!(x.round_to_multiple_assign(3, Nearest), Less);
2868/// assert_eq!(x, -21);
2869///
2870/// let mut x = -10isize;
2871/// assert_eq!(x.round_to_multiple_assign(4, Nearest), Greater);
2872/// assert_eq!(x, -8);
2873///
2874/// let mut x = -14i8;
2875/// assert_eq!(x.round_to_multiple_assign(4, Nearest), Less);
2876/// assert_eq!(x, -16);
2877///
2878/// let mut x = -10i16;
2879/// assert_eq!(x.round_to_multiple_assign(-4, Down), Greater);
2880/// assert_eq!(x, -8);
2881///
2882/// let mut x = -10i32;
2883/// assert_eq!(x.round_to_multiple_assign(-4, Up), Less);
2884/// assert_eq!(x, -12);
2885///
2886/// let mut x = -10i64;
2887/// assert_eq!(x.round_to_multiple_assign(-5, Exact), Equal);
2888/// assert_eq!(x, -10);
2889///
2890/// let mut x = -10i128;
2891/// assert_eq!(x.round_to_multiple_assign(-3, Nearest), Greater);
2892/// assert_eq!(x, -9);
2893///
2894/// let mut x = -20isize;
2895/// assert_eq!(x.round_to_multiple_assign(-3, Nearest), Less);
2896/// assert_eq!(x, -21);
2897///
2898/// let mut x = -10i8;
2899/// assert_eq!(x.round_to_multiple_assign(-4, Nearest), Greater);
2900/// assert_eq!(x, -8);
2901///
2902/// let mut x = -14i16;
2903/// assert_eq!(x.round_to_multiple_assign(-4, Nearest), Less);
2904/// assert_eq!(x, -16);
2905/// ```
2906pub mod round_to_multiple;
2907/// [`RoundToMultipleOfPowerOf2`](traits::RoundToMultipleOfPowerOf2) and
2908/// [`RoundToMultipleOfPowerOf2Assign`](traits::RoundToMultipleOfPowerOf2Assign), traits for
2909/// rounding a number to a multiple of a power of 2.
2910///
2911/// # round_to_multiple_of_power_of_2
2912/// ```
2913/// use malachite_base::num::arithmetic::traits::RoundToMultipleOfPowerOf2;
2914/// use malachite_base::rounding_modes::RoundingMode::*;
2915/// use std::cmp::Ordering::*;
2916///
2917/// assert_eq!(10u8.round_to_multiple_of_power_of_2(2, Floor), (8, Less));
2918/// assert_eq!(
2919/// 10u8.round_to_multiple_of_power_of_2(2, Ceiling),
2920/// (12, Greater)
2921/// );
2922/// assert_eq!(10u8.round_to_multiple_of_power_of_2(2, Down), (8, Less));
2923/// assert_eq!(10u8.round_to_multiple_of_power_of_2(2, Up), (12, Greater));
2924/// assert_eq!(10u8.round_to_multiple_of_power_of_2(2, Nearest), (8, Less));
2925/// assert_eq!(12u8.round_to_multiple_of_power_of_2(2, Exact), (12, Equal));
2926///
2927/// assert_eq!(
2928/// (-10i8).round_to_multiple_of_power_of_2(2, Floor),
2929/// (-12, Less)
2930/// );
2931/// assert_eq!(
2932/// (-10i8).round_to_multiple_of_power_of_2(2, Ceiling),
2933/// (-8, Greater)
2934/// );
2935/// assert_eq!(
2936/// (-10i8).round_to_multiple_of_power_of_2(2, Down),
2937/// (-8, Greater)
2938/// );
2939/// assert_eq!((-10i8).round_to_multiple_of_power_of_2(2, Up), (-12, Less));
2940/// assert_eq!(
2941/// (-10i8).round_to_multiple_of_power_of_2(2, Nearest),
2942/// (-8, Greater)
2943/// );
2944/// assert_eq!(
2945/// (-12i8).round_to_multiple_of_power_of_2(2, Exact),
2946/// (-12, Equal)
2947/// );
2948/// ```
2949///
2950/// # round_to_multiple_of_power_of_2_assign
2951/// ```
2952/// use malachite_base::num::arithmetic::traits::RoundToMultipleOfPowerOf2Assign;
2953/// use malachite_base::rounding_modes::RoundingMode::*;
2954/// use std::cmp::Ordering::*;
2955///
2956/// let mut x = 10u8;
2957/// assert_eq!(x.round_to_multiple_of_power_of_2_assign(2, Floor), Less);
2958/// assert_eq!(x, 8);
2959///
2960/// let mut x = 10u8;
2961/// assert_eq!(
2962/// x.round_to_multiple_of_power_of_2_assign(2, Ceiling),
2963/// Greater
2964/// );
2965/// assert_eq!(x, 12);
2966///
2967/// let mut x = 10u8;
2968/// assert_eq!(x.round_to_multiple_of_power_of_2_assign(2, Down), Less);
2969/// assert_eq!(x, 8);
2970///
2971/// let mut x = 10u8;
2972/// assert_eq!(x.round_to_multiple_of_power_of_2_assign(2, Up), Greater);
2973/// assert_eq!(x, 12);
2974///
2975/// let mut x = 10u8;
2976/// assert_eq!(x.round_to_multiple_of_power_of_2_assign(2, Nearest), Less);
2977/// assert_eq!(x, 8);
2978///
2979/// let mut x = 12u8;
2980/// assert_eq!(x.round_to_multiple_of_power_of_2_assign(2, Exact), Equal);
2981/// assert_eq!(x, 12);
2982///
2983/// let mut x = -10i8;
2984/// assert_eq!(x.round_to_multiple_of_power_of_2_assign(2, Floor), Less);
2985/// assert_eq!(x, -12);
2986///
2987/// let mut x = -10i8;
2988/// assert_eq!(
2989/// x.round_to_multiple_of_power_of_2_assign(2, Ceiling),
2990/// Greater
2991/// );
2992/// assert_eq!(x, -8);
2993///
2994/// let mut x = -10i8;
2995/// assert_eq!(x.round_to_multiple_of_power_of_2_assign(2, Down), Greater);
2996/// assert_eq!(x, -8);
2997///
2998/// let mut x = -10i8;
2999/// assert_eq!(x.round_to_multiple_of_power_of_2_assign(2, Up), Less);
3000/// assert_eq!(x, -12);
3001///
3002/// let mut x = -10i8;
3003/// assert_eq!(
3004/// x.round_to_multiple_of_power_of_2_assign(2, Nearest),
3005/// Greater
3006/// );
3007/// assert_eq!(x, -8);
3008///
3009/// let mut x = -12i8;
3010/// assert_eq!(x.round_to_multiple_of_power_of_2_assign(2, Exact), Equal);
3011/// assert_eq!(x, -12);
3012/// ```
3013pub mod round_to_multiple_of_power_of_2;
3014/// [`SaturatingAbs`](traits::SaturatingAbs) and
3015/// [`SaturatingAbsAssign`](traits::SaturatingAbsAssign), traits for taking the absolute value of a
3016/// number and saturating at numeric bounds instead of overflowing.
3017///
3018/// # saturating_abs_assign
3019/// ```
3020/// use malachite_base::num::arithmetic::traits::SaturatingAbsAssign;
3021///
3022/// let mut x = 0i8;
3023/// x.saturating_abs_assign();
3024/// assert_eq!(x, 0);
3025///
3026/// let mut x = 100i64;
3027/// x.saturating_abs_assign();
3028/// assert_eq!(x, 100);
3029///
3030/// let mut x = -100i64;
3031/// x.saturating_abs_assign();
3032/// assert_eq!(x, 100);
3033///
3034/// let mut x = -128i8;
3035/// x.saturating_abs_assign();
3036/// assert_eq!(x, 127);
3037/// ```
3038pub mod saturating_abs;
3039/// [`SaturatingAdd`](traits::SaturatingAdd) and
3040/// [`SaturatingAddAssign`](traits::SaturatingAddAssign), traits for adding two numbers and
3041/// saturating at numeric bounds instead of overflowing.
3042///
3043/// # saturating_add_assign
3044/// ```
3045/// use malachite_base::num::arithmetic::traits::SaturatingAddAssign;
3046///
3047/// let mut x = 123u16;
3048/// x.saturating_add_assign(456);
3049/// assert_eq!(x, 579);
3050///
3051/// let mut x = 123u8;
3052/// x.saturating_add_assign(200);
3053/// assert_eq!(x, 255);
3054/// ```
3055pub mod saturating_add;
3056/// [`SaturatingAddMul`](traits::SaturatingAddMul) and
3057/// [`SaturatingAddMulAssign`](traits::SaturatingAddMulAssign), traits for adding the product of two
3058/// numbers to a number and saturating at numeric bounds instead of overflowing.
3059///
3060/// # saturating_add_mul
3061/// ```
3062/// use malachite_base::num::arithmetic::traits::SaturatingAddMul;
3063///
3064/// assert_eq!(2u8.saturating_add_mul(3, 7), 23);
3065/// assert_eq!(2u8.saturating_add_mul(20, 20), 255);
3066///
3067/// assert_eq!(127i8.saturating_add_mul(-2, 100), -73);
3068/// assert_eq!((-127i8).saturating_add_mul(-2, 100), -128);
3069/// ```
3070///
3071/// # saturating_add_mul_assign
3072/// ```
3073/// use malachite_base::num::arithmetic::traits::SaturatingAddMulAssign;
3074///
3075/// let mut x = 2u8;
3076/// x.saturating_add_mul_assign(3, 7);
3077/// assert_eq!(x, 23);
3078///
3079/// let mut x = 2u8;
3080/// x.saturating_add_mul_assign(20, 20);
3081/// assert_eq!(x, 255);
3082///
3083/// let mut x = 127i8;
3084/// x.saturating_add_mul_assign(-2, 100);
3085/// assert_eq!(x, -73);
3086///
3087/// let mut x = -127i8;
3088/// x.saturating_add_mul_assign(-2, 100);
3089/// assert_eq!(x, -128);
3090/// ```
3091pub mod saturating_add_mul;
3092/// [`SaturatingMul`](traits::SaturatingMul) and
3093/// [`SaturatingMulAssign`](traits::SaturatingMulAssign), traits for multiplying two numbers and
3094/// saturating at numeric bounds instead of overflowing.
3095///
3096/// # saturating_mul_assign
3097/// ```
3098/// use malachite_base::num::arithmetic::traits::SaturatingMulAssign;
3099///
3100/// let mut x = 123u16;
3101/// x.saturating_mul_assign(456);
3102/// assert_eq!(x, 56088);
3103///
3104/// let mut x = 123u8;
3105/// x.saturating_mul_assign(200);
3106/// assert_eq!(x, 255);
3107/// ```
3108pub mod saturating_mul;
3109/// [`SaturatingNeg`](traits::SaturatingNeg) and
3110/// [`SaturatingNegAssign`](traits::SaturatingNegAssign), traits for negating a number and
3111/// saturating at numeric bounds instead of overflowing.
3112///
3113/// # saturating_neg_assign
3114/// ```
3115/// use malachite_base::num::arithmetic::traits::SaturatingNegAssign;
3116///
3117/// let mut x = 0i8;
3118/// x.saturating_neg_assign();
3119/// assert_eq!(x, 0);
3120///
3121/// let mut x = 100i64;
3122/// x.saturating_neg_assign();
3123/// assert_eq!(x, -100);
3124///
3125/// let mut x = -100i64;
3126/// x.saturating_neg_assign();
3127/// assert_eq!(x, 100);
3128///
3129/// let mut x = -128i8;
3130/// x.saturating_neg_assign();
3131/// assert_eq!(x, 127);
3132/// ```
3133pub mod saturating_neg;
3134/// [`SaturatingPow`](traits::SaturatingPow) and
3135/// [`SaturatingPowAssign`](traits::SaturatingPowAssign), traits for raising a number to a power and
3136/// saturating at numeric bounds instead of overflowing.
3137///
3138/// # saturating_pow_assign
3139/// ```
3140/// use malachite_base::num::arithmetic::traits::SaturatingPowAssign;
3141///
3142/// let mut x = 3u8;
3143/// x.saturating_pow_assign(3);
3144/// assert_eq!(x, 27);
3145///
3146/// let mut x = -10i32;
3147/// x.saturating_pow_assign(9);
3148/// assert_eq!(x, -1000000000);
3149///
3150/// let mut x = -10i16;
3151/// x.saturating_pow_assign(9);
3152/// assert_eq!(x, -32768);
3153/// ```
3154pub mod saturating_pow;
3155/// [`SaturatingSquare`](traits::SaturatingSquare) and
3156/// [`SaturatingSquareAssign`](traits::SaturatingSquareAssign), traits for squaring a number and
3157/// saturating at numeric bounds instead of overflowing.
3158///
3159/// # saturating_square
3160/// ```
3161/// use malachite_base::num::arithmetic::traits::SaturatingSquare;
3162///
3163/// assert_eq!(3u8.saturating_square(), 9);
3164/// assert_eq!((-1000i32).saturating_square(), 1000000);
3165/// assert_eq!(1000u16.saturating_square(), u16::MAX);
3166/// ```
3167///
3168/// # saturating_square_assign
3169/// ```
3170/// use malachite_base::num::arithmetic::traits::SaturatingSquareAssign;
3171///
3172/// let mut x = 3u8;
3173/// x.saturating_square_assign();
3174/// assert_eq!(x, 9);
3175///
3176/// let mut x = -1000i32;
3177/// x.saturating_square_assign();
3178/// assert_eq!(x, 1000000);
3179///
3180/// let mut x = 1000u16;
3181/// x.saturating_square_assign();
3182/// assert_eq!(x, u16::MAX);
3183/// ```
3184pub mod saturating_square;
3185/// [`SaturatingSub`](traits::SaturatingSub) and
3186/// [`SaturatingSubAssign`](traits::SaturatingSubAssign), traits for subtracting two numbers and
3187/// saturating at numeric bounds instead of overflowing.
3188///
3189/// # saturating_sub_assign
3190/// ```
3191/// use malachite_base::num::arithmetic::traits::SaturatingSubAssign;
3192///
3193/// let mut x = 456u16;
3194/// x.saturating_sub_assign(123);
3195/// assert_eq!(x, 333);
3196///
3197/// let mut x = 123u16;
3198/// x.saturating_sub_assign(456);
3199/// assert_eq!(x, 0);
3200/// ```
3201pub mod saturating_sub;
3202/// [`SaturatingSubMul`](traits::SaturatingSubMul) and
3203/// [`SaturatingSubMulAssign`](traits::SaturatingSubMulAssign), traits for subtracting a number by
3204/// the product of two numbers and saturating at numeric bounds instead of overflowing.
3205///
3206/// # saturating_sub_mul
3207/// ```
3208/// use malachite_base::num::arithmetic::traits::SaturatingSubMul;
3209///
3210/// assert_eq!(60u8.saturating_sub_mul(5, 10), 10);
3211/// assert_eq!(2u8.saturating_sub_mul(10, 5), 0);
3212///
3213/// assert_eq!(127i8.saturating_sub_mul(2, 100), -73);
3214/// assert_eq!((-127i8).saturating_sub_mul(2, 100), -128);
3215/// ```
3216///
3217/// # saturating_sub_mul_assign
3218/// ```
3219/// use malachite_base::num::arithmetic::traits::SaturatingSubMulAssign;
3220///
3221/// let mut x = 60u8;
3222/// x.saturating_sub_mul_assign(5, 10);
3223/// assert_eq!(x, 10);
3224///
3225/// let mut x = 2u8;
3226/// x.saturating_sub_mul_assign(10, 5);
3227/// assert_eq!(x, 0);
3228///
3229/// let mut x = 127i8;
3230/// x.saturating_sub_mul_assign(2, 100);
3231/// assert_eq!(x, -73);
3232///
3233/// let mut x = -127i8;
3234/// x.saturating_sub_mul_assign(2, 100);
3235/// assert_eq!(x, -128);
3236/// ```
3237pub mod saturating_sub_mul;
3238/// [`ShlRound`](traits::ShlRound) and [`ShlRoundAssign`](traits::ShlRoundAssign), traits for
3239/// multiplying a number by a power of 2 and rounding according to a specified
3240/// [`RoundingMode`](crate::rounding_modes::RoundingMode).
3241///
3242/// # shl_round
3243/// ```
3244/// use malachite_base::num::arithmetic::traits::ShlRound;
3245/// use malachite_base::rounding_modes::RoundingMode::*;
3246/// use std::cmp::Ordering::*;
3247///
3248/// assert_eq!(0x101u16.shl_round(-8i8, Down), (1, Less));
3249/// assert_eq!(0x101u32.shl_round(-8i16, Up), (2, Greater));
3250///
3251/// assert_eq!((-0x101i16).shl_round(-9i32, Down), (0, Greater));
3252/// assert_eq!((-0x101i32).shl_round(-9i64, Up), (-1, Less));
3253/// assert_eq!((-0x101i64).shl_round(-9i8, Nearest), (-1, Less));
3254/// assert_eq!((-0xffi32).shl_round(-9i16, Nearest), (0, Greater));
3255/// assert_eq!((-0x100i16).shl_round(-9i32, Nearest), (0, Greater));
3256///
3257/// assert_eq!(0x100u64.shl_round(-8i64, Exact), (1, Equal));
3258/// ```
3259///
3260/// # shl_round_assign
3261/// ```
3262/// use malachite_base::num::arithmetic::traits::ShlRoundAssign;
3263/// use malachite_base::rounding_modes::RoundingMode::*;
3264/// use std::cmp::Ordering::*;
3265///
3266/// let mut x = 0x101u16;
3267/// assert_eq!(x.shl_round_assign(-8i8, Down), Less);
3268/// assert_eq!(x, 1);
3269///
3270/// let mut x = 0x101u32;
3271/// assert_eq!(x.shl_round_assign(-8i16, Up), Greater);
3272/// assert_eq!(x, 2);
3273///
3274/// let mut x = -0x101i16;
3275/// assert_eq!(x.shl_round_assign(-9i32, Down), Greater);
3276/// assert_eq!(x, 0);
3277///
3278/// let mut x = -0x101i32;
3279/// assert_eq!(x.shl_round_assign(-9i64, Up), Less);
3280/// assert_eq!(x, -1);
3281///
3282/// let mut x = -0x101i64;
3283/// assert_eq!(x.shl_round_assign(-9i8, Nearest), Less);
3284/// assert_eq!(x, -1);
3285///
3286/// let mut x = -0xffi32;
3287/// assert_eq!(x.shl_round_assign(-9i16, Nearest), Greater);
3288/// assert_eq!(x, 0);
3289///
3290/// let mut x = -0x100i16;
3291/// assert_eq!(x.shl_round_assign(-9i32, Nearest), Greater);
3292/// assert_eq!(x, 0);
3293///
3294/// let mut x = 0x100u64;
3295/// assert_eq!(x.shl_round_assign(-8i64, Exact), Equal);
3296/// assert_eq!(x, 1);
3297/// ```
3298pub mod shl_round;
3299/// [`ShrRound`](traits::ShrRound) and [`ShrRoundAssign`](traits::ShrRoundAssign), traits for
3300/// dividing a number by a power of 2 and rounding according to a specified
3301/// [`RoundingMode`](crate::rounding_modes::RoundingMode).
3302///
3303/// # shr_round
3304/// ```
3305/// use malachite_base::num::arithmetic::traits::ShrRound;
3306/// use malachite_base::rounding_modes::RoundingMode::*;
3307/// use std::cmp::Ordering::*;
3308///
3309/// assert_eq!(0x101u32.shr_round(8u8, Down), (1, Less));
3310/// assert_eq!(0x101u16.shr_round(8u16, Up), (2, Greater));
3311///
3312/// assert_eq!(0x101u64.shr_round(9u32, Down), (0, Less));
3313/// assert_eq!(0x101u32.shr_round(9u64, Up), (1, Greater));
3314/// assert_eq!(0x101u16.shr_round(9u8, Nearest), (1, Greater));
3315/// assert_eq!(0xffu8.shr_round(9u16, Nearest), (0, Less));
3316/// assert_eq!(0x100u32.shr_round(9u32, Nearest), (0, Less));
3317///
3318/// assert_eq!(0x100u32.shr_round(8u64, Exact), (1, Equal));
3319///
3320/// assert_eq!(0x101i32.shr_round(8u8, Down), (1, Less));
3321/// assert_eq!(0x101i16.shr_round(8u16, Up), (2, Greater));
3322///
3323/// assert_eq!((-0x101i32).shr_round(9u32, Down), (0, Greater));
3324/// assert_eq!((-0x101i64).shr_round(9u64, Up), (-1, Less));
3325/// assert_eq!((-0x101i16).shr_round(9u8, Nearest), (-1, Less));
3326/// assert_eq!((-0xffi32).shr_round(9u16, Nearest), (0, Greater));
3327/// assert_eq!((-0x100i64).shr_round(9u32, Nearest), (0, Greater));
3328///
3329/// assert_eq!(0x100i32.shr_round(8u64, Exact), (1, Equal));
3330///
3331/// assert_eq!(0x101u32.shr_round(8i8, Down), (1, Less));
3332/// assert_eq!(0x101u16.shr_round(8i16, Up), (2, Greater));
3333///
3334/// assert_eq!((-0x101i32).shr_round(9i32, Down), (0, Greater));
3335/// assert_eq!((-0x101i64).shr_round(9i64, Up), (-1, Less));
3336/// assert_eq!((-0x101i16).shr_round(9i8, Nearest), (-1, Less));
3337/// assert_eq!((-0xffi32).shr_round(9i16, Nearest), (0, Greater));
3338/// assert_eq!((-0x100i64).shr_round(9i32, Nearest), (0, Greater));
3339///
3340/// assert_eq!(0x100u32.shr_round(8i64, Exact), (1, Equal));
3341/// ```
3342///
3343/// # shr_round_assign
3344/// ```
3345/// use malachite_base::num::arithmetic::traits::ShrRoundAssign;
3346/// use malachite_base::rounding_modes::RoundingMode::*;
3347/// use std::cmp::Ordering::*;
3348///
3349/// let mut x = 0x101u32;
3350/// assert_eq!(x.shr_round_assign(8u8, Down), Less);
3351/// assert_eq!(x, 1);
3352///
3353/// let mut x = 0x101u16;
3354/// assert_eq!(x.shr_round_assign(8u16, Up), Greater);
3355/// assert_eq!(x, 2);
3356///
3357/// let mut x = 0x101u64;
3358/// assert_eq!(x.shr_round_assign(9u32, Down), Less);
3359/// assert_eq!(x, 0);
3360///
3361/// let mut x = 0x101u32;
3362/// assert_eq!(x.shr_round_assign(9u64, Up), Greater);
3363/// assert_eq!(x, 1);
3364///
3365/// let mut x = 0x101u16;
3366/// assert_eq!(x.shr_round_assign(9u8, Nearest), Greater);
3367/// assert_eq!(x, 1);
3368///
3369/// let mut x = 0xffu8;
3370/// assert_eq!(x.shr_round_assign(9u16, Nearest), Less);
3371/// assert_eq!(x, 0);
3372///
3373/// let mut x = 0x100u32;
3374/// assert_eq!(x.shr_round_assign(9u32, Nearest), Less);
3375/// assert_eq!(x, 0);
3376///
3377/// let mut x = 0x100u32;
3378/// assert_eq!(x.shr_round_assign(8u64, Exact), Equal);
3379/// assert_eq!(x, 1);
3380///
3381/// let mut x = 0x101i32;
3382/// assert_eq!(x.shr_round_assign(8u8, Down), Less);
3383/// assert_eq!(x, 1);
3384///
3385/// let mut x = 0x101i16;
3386/// assert_eq!(x.shr_round_assign(8u16, Up), Greater);
3387/// assert_eq!(x, 2);
3388///
3389/// let mut x = -0x101i32;
3390/// assert_eq!(x.shr_round_assign(9u32, Down), Greater);
3391/// assert_eq!(x, 0);
3392///
3393/// let mut x = -0x101i64;
3394/// assert_eq!(x.shr_round_assign(9u64, Up), Less);
3395/// assert_eq!(x, -1);
3396///
3397/// let mut x = -0x101i16;
3398/// assert_eq!(x.shr_round_assign(9u8, Nearest), Less);
3399/// assert_eq!(x, -1);
3400///
3401/// let mut x = -0xffi32;
3402/// assert_eq!(x.shr_round_assign(9u16, Nearest), Greater);
3403/// assert_eq!(x, 0);
3404///
3405/// let mut x = -0x100i64;
3406/// assert_eq!(x.shr_round_assign(9u32, Nearest), Greater);
3407/// assert_eq!(x, 0);
3408///
3409/// let mut x = 0x100u32;
3410/// assert_eq!(x.shr_round_assign(8i64, Exact), Equal);
3411/// assert_eq!(x, 1);
3412///
3413/// let mut x = 0x101u32;
3414/// assert_eq!(x.shr_round_assign(8i8, Down), Less);
3415/// assert_eq!(x, 1);
3416///
3417/// let mut x = 0x101u16;
3418/// assert_eq!(x.shr_round_assign(8i16, Up), Greater);
3419/// assert_eq!(x, 2);
3420///
3421/// let mut x = -0x101i32;
3422/// assert_eq!(x.shr_round_assign(9i32, Down), Greater);
3423/// assert_eq!(x, 0);
3424///
3425/// let mut x = -0x101i64;
3426/// assert_eq!(x.shr_round_assign(9i64, Up), Less);
3427/// assert_eq!(x, -1);
3428///
3429/// let mut x = -0x101i16;
3430/// assert_eq!(x.shr_round_assign(9i8, Nearest), Less);
3431/// assert_eq!(x, -1);
3432///
3433/// let mut x = -0xffi32;
3434/// assert_eq!(x.shr_round_assign(9i16, Nearest), Greater);
3435/// assert_eq!(x, 0);
3436///
3437/// let mut x = -0x100i64;
3438/// assert_eq!(x.shr_round_assign(9i32, Nearest), Greater);
3439/// assert_eq!(x, 0);
3440///
3441/// let mut x = 0x100u32;
3442/// assert_eq!(x.shr_round_assign(8i64, Exact), Equal);
3443/// assert_eq!(x, 1);
3444/// ```
3445pub mod shr_round;
3446/// [`Sign`](traits::Sign), a trait for determining the sign of a number.
3447///
3448/// # sign
3449/// ```
3450/// use malachite_base::num::arithmetic::traits::Sign;
3451/// use malachite_base::num::basic::traits::NegativeInfinity;
3452/// use std::cmp::Ordering::*;
3453///
3454/// assert_eq!(0u8.sign(), Equal);
3455/// assert_eq!(100u64.sign(), Greater);
3456/// assert_eq!((-100i16).sign(), Less);
3457///
3458/// assert_eq!(0.0.sign(), Greater);
3459/// assert_eq!(1.0.sign(), Greater);
3460/// assert_eq!(f64::INFINITY.sign(), Greater);
3461///
3462/// assert_eq!((-0.0).sign(), Less);
3463/// assert_eq!((-1.0).sign(), Less);
3464/// assert_eq!(f64::NEGATIVE_INFINITY.sign(), Less);
3465///
3466/// assert_eq!(f64::NAN.sign(), Equal);
3467/// ```
3468pub mod sign;
3469/// Traits for taking the square root of a number.
3470///
3471/// The traits are [`FloorSqrt`](traits::FloorSqrt), [`FloorSqrtAssign`](traits::FloorSqrtAssign),
3472/// [`CeilingSqrt`](traits::CeilingSqrt), [`CeilingSqrtAssign`](traits::CeilingSqrtAssign),
3473/// [`CheckedSqrt`](traits::CheckedSqrt), [`SqrtRem`](traits::SqrtRem),
3474/// [`SqrtAssignRem`](traits::SqrtAssignRem), and [`SqrtAssign`](traits::SqrtAssign).
3475///
3476/// # floor_sqrt
3477/// ```
3478/// use malachite_base::num::arithmetic::traits::FloorSqrt;
3479///
3480/// assert_eq!(99u8.floor_sqrt(), 9);
3481/// assert_eq!(100u8.floor_sqrt(), 10);
3482/// assert_eq!(101u8.floor_sqrt(), 10);
3483/// assert_eq!(1000000000i32.floor_sqrt(), 31622);
3484/// assert_eq!(10000000000i64.floor_sqrt(), 100000);
3485/// ```
3486///
3487/// # floor_sqrt_assign
3488/// ```
3489/// use malachite_base::num::arithmetic::traits::FloorSqrtAssign;
3490///
3491/// let mut x = 99u8;
3492/// x.floor_sqrt_assign();
3493/// assert_eq!(x, 9);
3494///
3495/// let mut x = 100u8;
3496/// x.floor_sqrt_assign();
3497/// assert_eq!(x, 10);
3498///
3499/// let mut x = 101u8;
3500/// x.floor_sqrt_assign();
3501/// assert_eq!(x, 10);
3502///
3503/// let mut x = 1000000000i32;
3504/// x.floor_sqrt_assign();
3505/// assert_eq!(x, 31622);
3506///
3507/// let mut x = 10000000000i64;
3508/// x.floor_sqrt_assign();
3509/// assert_eq!(x, 100000);
3510/// ```
3511///
3512/// # ceiling_sqrt
3513/// ```
3514/// use malachite_base::num::arithmetic::traits::CeilingSqrt;
3515///
3516/// assert_eq!(99u8.ceiling_sqrt(), 10);
3517/// assert_eq!(100u8.ceiling_sqrt(), 10);
3518/// assert_eq!(101u8.ceiling_sqrt(), 11);
3519/// assert_eq!(1000000000u32.ceiling_sqrt(), 31623);
3520/// assert_eq!(10000000000u64.ceiling_sqrt(), 100000);
3521/// ```
3522///
3523/// # ceiling_sqrt_assign
3524/// ```
3525/// use malachite_base::num::arithmetic::traits::CeilingSqrtAssign;
3526///
3527/// let mut x = 99u8;
3528/// x.ceiling_sqrt_assign();
3529/// assert_eq!(x, 10);
3530///
3531/// let mut x = 100u8;
3532/// x.ceiling_sqrt_assign();
3533/// assert_eq!(x, 10);
3534///
3535/// let mut x = 101u8;
3536/// x.ceiling_sqrt_assign();
3537/// assert_eq!(x, 11);
3538///
3539/// let mut x = 1000000000i32;
3540/// x.ceiling_sqrt_assign();
3541/// assert_eq!(x, 31623);
3542///
3543/// let mut x = 10000000000i64;
3544/// x.ceiling_sqrt_assign();
3545/// assert_eq!(x, 100000);
3546/// ```
3547///
3548/// # checked_sqrt
3549/// ```
3550/// use malachite_base::num::arithmetic::traits::CheckedSqrt;
3551///
3552/// assert_eq!(99u8.checked_sqrt(), None);
3553/// assert_eq!(100u8.checked_sqrt(), Some(10));
3554/// assert_eq!(101u8.checked_sqrt(), None);
3555/// assert_eq!(1000000000i32.checked_sqrt(), None);
3556/// assert_eq!(10000000000i64.checked_sqrt(), Some(100000));
3557/// ```
3558///
3559/// # sqrt_rem
3560/// ```
3561/// use malachite_base::num::arithmetic::traits::SqrtRem;
3562///
3563/// assert_eq!(99u8.sqrt_rem(), (9, 18));
3564/// assert_eq!(100u8.sqrt_rem(), (10, 0));
3565/// assert_eq!(101u8.sqrt_rem(), (10, 1));
3566/// assert_eq!(1000000000u32.sqrt_rem(), (31622, 49116));
3567/// assert_eq!(10000000000u64.sqrt_rem(), (100000, 0));
3568/// ```
3569///
3570/// # sqrt_assign_rem
3571/// ```
3572/// use malachite_base::num::arithmetic::traits::SqrtAssignRem;
3573///
3574/// let mut x = 99u8;
3575/// assert_eq!(x.sqrt_assign_rem(), 18);
3576/// assert_eq!(x, 9);
3577///
3578/// let mut x = 100u8;
3579/// assert_eq!(x.sqrt_assign_rem(), 0);
3580/// assert_eq!(x, 10);
3581///
3582/// let mut x = 101u8;
3583/// assert_eq!(x.sqrt_assign_rem(), 1);
3584/// assert_eq!(x, 10);
3585///
3586/// let mut x = 1000000000u32;
3587/// assert_eq!(x.sqrt_assign_rem(), 49116);
3588/// assert_eq!(x, 31622);
3589///
3590/// let mut x = 10000000000u64;
3591/// assert_eq!(x.sqrt_assign_rem(), 0);
3592/// assert_eq!(x, 100000);
3593/// ```
3594///
3595/// # sqrt_assign
3596/// ```
3597/// use malachite_base::num::arithmetic::traits::SqrtAssign;
3598/// use malachite_base::num::float::NiceFloat;
3599///
3600/// let mut x = 4.0f64;
3601/// x.sqrt_assign();
3602/// assert_eq!(NiceFloat(x), NiceFloat(2.0));
3603///
3604/// let mut x = 2.0f64;
3605/// x.sqrt_assign();
3606/// assert_eq!(NiceFloat(x), NiceFloat(std::f64::consts::SQRT_2));
3607/// ```
3608pub mod sqrt;
3609/// [`Square`](traits::Square) and [`SquareAssign`](traits::SquareAssign), traits for squaring a
3610/// number.
3611///
3612/// # square
3613/// ```
3614/// use malachite_base::num::arithmetic::traits::Square;
3615///
3616/// assert_eq!(3u8.square(), 9);
3617/// assert_eq!((-1000i32).square(), 1000000);
3618/// assert_eq!(1.5f32.square(), 2.25);
3619/// ```
3620///
3621/// # square_assign
3622/// ```
3623/// use malachite_base::num::arithmetic::traits::SquareAssign;
3624///
3625/// let mut x = 3u8;
3626/// x.square_assign();
3627/// assert_eq!(x, 9);
3628///
3629/// let mut x = -1000i32;
3630/// x.square_assign();
3631/// assert_eq!(x, 1000000);
3632///
3633/// let mut x = 1.5f32;
3634/// x.square_assign();
3635/// assert_eq!(x, 2.25);
3636/// ```
3637pub mod square;
3638/// [`SubMul`](traits::SubMul) and [`SubMulAssign`](traits::SubMulAssign), traits for subtracting
3639/// the product of two numbers from a number.
3640///
3641/// # sub_mul
3642/// ```
3643/// use malachite_base::num::arithmetic::traits::SubMul;
3644///
3645/// assert_eq!(60u32.sub_mul(5, 10), 10);
3646/// assert_eq!(127i8.sub_mul(2, 100), -73);
3647/// assert_eq!(1.0f32.sub_mul(2.0, 3.0), -5.0);
3648/// ```
3649///
3650/// # sub_mul_assign
3651/// ```
3652/// use malachite_base::num::arithmetic::traits::SubMulAssign;
3653///
3654/// let mut x = 60u32;
3655/// x.sub_mul_assign(5, 10);
3656/// assert_eq!(x, 10);
3657///
3658/// let mut x = 127i8;
3659/// x.sub_mul_assign(2, 100);
3660/// assert_eq!(x, -73);
3661///
3662/// let mut x = 1.0f32;
3663/// x.sub_mul_assign(2.0, 3.0);
3664/// assert_eq!(x, -5.0);
3665/// ```
3666pub mod sub_mul;
3667/// Various traits for performing arithmetic operations on numbers.
3668pub mod traits;
3669/// [`WrappingAbs`](traits::WrappingAbs) and [`WrappingAbsAssign`](traits::WrappingAbsAssign),
3670/// traits for computing the absolute value of a number and wrapping at the boundary of the type.
3671///
3672/// # wrapping_abs_assign
3673/// ```
3674/// use malachite_base::num::arithmetic::traits::WrappingAbsAssign;
3675///
3676/// let mut x = 0i8;
3677/// x.wrapping_abs_assign();
3678/// assert_eq!(x, 0);
3679///
3680/// let mut x = 100i64;
3681/// x.wrapping_abs_assign();
3682/// assert_eq!(x, 100);
3683///
3684/// let mut x = -100i64;
3685/// x.wrapping_abs_assign();
3686/// assert_eq!(x, 100);
3687///
3688/// let mut x = -128i8;
3689/// x.wrapping_abs_assign();
3690/// assert_eq!(x, -128);
3691/// ```
3692pub mod wrapping_abs;
3693/// [`WrappingAdd`](traits::WrappingAdd) and [`WrappingAddAssign`](traits::WrappingAddAssign),
3694/// traits for adding two numbers and wrapping at the boundary of the type.
3695///
3696/// # wrapping_add_assign
3697/// ```
3698/// use malachite_base::num::arithmetic::traits::WrappingAddAssign;
3699///
3700/// let mut x = 123u16;
3701/// x.wrapping_add_assign(456);
3702/// assert_eq!(x, 579);
3703///
3704/// let mut x = 123u8;
3705/// x.wrapping_add_assign(200);
3706/// assert_eq!(x, 67);
3707/// ```
3708pub mod wrapping_add;
3709/// [`WrappingAddMul`](traits::WrappingAddMul) and
3710/// [`WrappingAddMulAssign`](traits::WrappingAddMulAssign), traits for adding the product of two
3711/// numbers to a third and wrapping at the boundary of the type.
3712///
3713/// # wrapping_add_mul
3714/// ```
3715/// use malachite_base::num::arithmetic::traits::WrappingAddMul;
3716///
3717/// assert_eq!(2u8.wrapping_add_mul(3, 7), 23);
3718/// assert_eq!((-127i8).wrapping_add_mul(-2, 100), -71);
3719/// ```
3720///
3721/// # wrapping_add_mul_assign
3722/// ```
3723/// use malachite_base::num::arithmetic::traits::WrappingAddMulAssign;
3724///
3725/// let mut x = 2u8;
3726/// x.wrapping_add_mul_assign(3, 7);
3727/// assert_eq!(x, 23);
3728///
3729/// let mut x = -127i8;
3730/// x.wrapping_add_mul_assign(-2, 100);
3731/// assert_eq!(x, -71);
3732/// ```
3733pub mod wrapping_add_mul;
3734/// [`WrappingDiv`](traits::WrappingDiv) and [`WrappingDivAssign`](traits::WrappingDivAssign),
3735/// traits for dividing two numbers and wrapping at the boundary of the type.
3736///
3737/// # wrapping_div_assign
3738/// ```
3739/// use malachite_base::num::arithmetic::traits::WrappingDivAssign;
3740///
3741/// let mut x = 100u16;
3742/// x.wrapping_div_assign(3);
3743/// assert_eq!(x, 33);
3744///
3745/// let mut x = -128i8;
3746/// x.wrapping_div_assign(-1);
3747/// assert_eq!(x, -128);
3748/// ```
3749pub mod wrapping_div;
3750/// [`WrappingMul`](traits::WrappingMul) and [`WrappingMulAssign`](traits::WrappingMulAssign),
3751/// traits for multiplying two numbers and wrapping at the boundary of the type.
3752///
3753/// # wrapping_mul_assign
3754/// ```
3755/// use malachite_base::num::arithmetic::traits::WrappingMulAssign;
3756///
3757/// let mut x = 123u16;
3758/// x.wrapping_mul_assign(456);
3759/// assert_eq!(x, 56088);
3760///
3761/// let mut x = 123u8;
3762/// x.wrapping_mul_assign(200);
3763/// assert_eq!(x, 24);
3764/// ```
3765pub mod wrapping_mul;
3766/// [`WrappingNeg`](traits::WrappingNeg) and [`WrappingNegAssign`](traits::WrappingNegAssign) for
3767/// negating a number and wrapping at the boundary of the type.
3768///
3769/// # wrapping_neg_assign
3770/// ```
3771/// use malachite_base::num::arithmetic::traits::WrappingNegAssign;
3772///
3773/// let mut x = 0i8;
3774/// x.wrapping_neg_assign();
3775/// assert_eq!(x, 0);
3776///
3777/// let mut x = 100u64;
3778/// x.wrapping_neg_assign();
3779/// assert_eq!(x, 18446744073709551516);
3780///
3781/// let mut x = -100i64;
3782/// x.wrapping_neg_assign();
3783/// assert_eq!(x, 100);
3784///
3785/// let mut x = -128i8;
3786/// x.wrapping_neg_assign();
3787/// assert_eq!(x, -128);
3788/// ```
3789pub mod wrapping_neg;
3790/// [`WrappingPow`](traits::WrappingPow) and [`WrappingPowAssign`](traits::WrappingPowAssign),
3791/// traits for raising a number to a power and wrapping at the boundary of the type.
3792///
3793/// # wrapping_pow_assign
3794/// ```
3795/// use malachite_base::num::arithmetic::traits::WrappingPowAssign;
3796///
3797/// let mut x = 3u8;
3798/// x.wrapping_pow_assign(3);
3799/// assert_eq!(x, 27);
3800///
3801/// let mut x = -10i32;
3802/// x.wrapping_pow_assign(9);
3803/// assert_eq!(x, -1000000000);
3804///
3805/// let mut x = -10i16;
3806/// x.wrapping_pow_assign(9);
3807/// assert_eq!(x, 13824);
3808/// ```
3809pub mod wrapping_pow;
3810/// [`WrappingSquare`](traits::WrappingSquare) and
3811/// [`WrappingSquareAssign`](traits::WrappingAbsAssign), traits for squaring a number and wrapping
3812/// at the boundary of the type.
3813///
3814/// # wrapping_square
3815/// ```
3816/// use malachite_base::num::arithmetic::traits::WrappingSquare;
3817///
3818/// assert_eq!(3u8.wrapping_square(), 9);
3819/// assert_eq!((-1000i32).wrapping_square(), 1000000);
3820/// assert_eq!(1000u16.wrapping_square(), 16960);
3821/// ```
3822///
3823/// # wrapping_square_assign
3824/// ```
3825/// use malachite_base::num::arithmetic::traits::WrappingSquareAssign;
3826///
3827/// let mut x = 3u8;
3828/// x.wrapping_square_assign();
3829/// assert_eq!(x, 9);
3830///
3831/// let mut x = -1000i32;
3832/// x.wrapping_square_assign();
3833/// assert_eq!(x, 1000000);
3834///
3835/// let mut x = 1000u16;
3836/// x.wrapping_square_assign();
3837/// assert_eq!(x, 16960);
3838/// ```
3839pub mod wrapping_square;
3840/// [`WrappingSub`](traits::WrappingSub) and [`WrappingSubAssign`](traits::WrappingSubAssign),
3841/// traits for subtracting two numbers and wrapping at the boundary of the type.
3842///
3843/// # wrapping_sub_assign
3844/// ```
3845/// use malachite_base::num::arithmetic::traits::WrappingSubAssign;
3846///
3847/// let mut x = 456u16;
3848/// x.wrapping_sub_assign(123);
3849/// assert_eq!(x, 333);
3850///
3851/// let mut x = 123u16;
3852/// x.wrapping_sub_assign(456);
3853/// assert_eq!(x, 65203);
3854/// ```
3855pub mod wrapping_sub;
3856/// [`WrappingSubMul`](traits::WrappingSubMul) and
3857/// [`WrappingSubMulAssign`](traits::WrappingSubMulAssign), traits for subtracting a number by the
3858/// product of two other numbers and wrapping at the boundary of the type.
3859///
3860/// # wrapping_sub_mul
3861/// ```
3862/// use malachite_base::num::arithmetic::traits::WrappingSubMul;
3863///
3864/// assert_eq!(127i8.wrapping_sub_mul(2, 100), -73);
3865/// assert_eq!((-127i8).wrapping_sub_mul(2, 100), -71);
3866/// ```
3867///
3868/// # wrapping_sub_mul_assign
3869/// ```
3870/// use malachite_base::num::arithmetic::traits::WrappingAddMulAssign;
3871///
3872/// let mut x = 2u8;
3873/// x.wrapping_add_mul_assign(3, 7);
3874/// assert_eq!(x, 23);
3875///
3876/// let mut x = -127i8;
3877/// x.wrapping_add_mul_assign(-2, 100);
3878/// assert_eq!(x, -71);
3879/// ```
3880pub mod wrapping_sub_mul;
3881/// [`XMulYToZZ`](traits::XMulYToZZ), a trait for multiplying two numbers and returning the result
3882/// as a double-width number.
3883///
3884/// # x_mul_y_to_zz
3885/// ```
3886/// use malachite_base::num::arithmetic::traits::XMulYToZZ;
3887///
3888/// assert_eq!(u64::x_mul_y_to_zz(15, 3), (0, 45));
3889/// assert_eq!(u8::x_mul_y_to_zz(0x78, 0x9a), (0x48, 0x30));
3890/// ```
3891pub mod x_mul_y_to_zz;
3892/// [`XXAddYYToZZ`](traits::XXAddYYToZZ), a trait for adding two double-width numbers and returning
3893/// the result as a double-width number.
3894///
3895/// # xx_add_yy_to_zz
3896/// ```
3897/// use malachite_base::num::arithmetic::traits::XXAddYYToZZ;
3898///
3899/// assert_eq!(u64::xx_add_yy_to_zz(0x12, 0x34, 0x33, 0x33), (0x45, 0x67));
3900/// assert_eq!(u8::xx_add_yy_to_zz(0x78, 0x9a, 0xbc, 0xde), (0x35, 0x78));
3901/// ```
3902pub mod xx_add_yy_to_zz;
3903/// [`XXDivModYToQR`](traits::XXDivModYToQR), a trait for dividing a double-width number by a
3904/// single-width number and returning the quotient and remainder.
3905///
3906/// # xx_div_mod_y_to_qr
3907/// ```
3908/// use malachite_base::num::arithmetic::traits::XXDivModYToQR;
3909///
3910/// assert_eq!(
3911/// u64::xx_div_mod_y_to_qr(0x12, 0x34, 0x33),
3912/// (0x5a5a5a5a5a5a5a5b, 0x13)
3913/// );
3914/// assert_eq!(u8::xx_div_mod_y_to_qr(0x78, 0x9a, 0xbc), (0xa4, 0x2a));
3915/// ```
3916pub mod xx_div_mod_y_to_qr;
3917/// [`XXSubYYToZZ`](traits::XXSubYYToZZ), a trait for subtracting two double-width numbers and
3918/// returning the result as a double-width number.
3919///
3920/// # xx_sub_yy_to_zz
3921/// ```
3922/// use malachite_base::num::arithmetic::traits::XXSubYYToZZ;
3923///
3924/// assert_eq!(u64::xx_sub_yy_to_zz(0x67, 0x89, 0x33, 0x33), (0x34, 0x56));
3925/// assert_eq!(u8::xx_sub_yy_to_zz(0x78, 0x9a, 0xbc, 0xde), (0xbb, 0xbc));
3926/// ```
3927pub mod xx_sub_yy_to_zz;
3928/// [`XXXAddYYYToZZZ`](traits::XXXAddYYYToZZZ), a trait for adding two triple-width numbers and
3929/// returning the result as a triple-width number.
3930///
3931/// # xxx_add_yyy_to_zzz
3932/// ```
3933/// use malachite_base::num::arithmetic::traits::XXXAddYYYToZZZ;
3934///
3935/// assert_eq!(
3936/// u64::xxx_add_yyy_to_zzz(0x12, 0x34, 0x56, 0x33, 0x33, 0x33),
3937/// (0x45, 0x67, 0x89)
3938/// );
3939/// assert_eq!(
3940/// u8::xxx_add_yyy_to_zzz(0x78, 0x9a, 0xbc, 0xde, 0xfe, 0xdc),
3941/// (0x57, 0x99, 0x98)
3942/// );
3943/// ```
3944pub mod xxx_add_yyy_to_zzz;
3945/// [`XXXSubYYYToZZZ`](traits::XXXSubYYYToZZZ), a trait for subtracting two triple-width numbers and
3946/// returning the result as a triple-width number.
3947///
3948/// # xxx_sub_yyy_to_zzz
3949/// ```
3950/// use malachite_base::num::arithmetic::traits::XXXSubYYYToZZZ;
3951///
3952/// assert_eq!(
3953/// u64::xxx_sub_yyy_to_zzz(0x67, 0x89, 0xab, 0x33, 0x33, 0x33),
3954/// (0x34, 0x56, 0x78)
3955/// );
3956/// assert_eq!(
3957/// u8::xxx_sub_yyy_to_zzz(0x78, 0x9a, 0xbc, 0xde, 0xfe, 0xdc),
3958/// (0x99, 0x9b, 0xe0)
3959/// );
3960/// ```
3961pub mod xxx_sub_yyy_to_zzz;
3962/// [`XXXXAddYYYYToZZZZ`](traits::XXXXAddYYYYToZZZZ), a trait for adding two quadruple-width numbers
3963/// and returning the result as a quadruple-width number.
3964///
3965/// # xxxx_add_yyyy_to_zzzz
3966/// ```
3967/// use malachite_base::num::arithmetic::traits::XXXXAddYYYYToZZZZ;
3968///
3969/// assert_eq!(
3970/// u64::xxxx_add_yyyy_to_zzzz(0x12, 0x34, 0x56, 0x78, 0x33, 0x33, 0x33, 0x33),
3971/// (0x45, 0x67, 0x89, 0xab)
3972/// );
3973/// assert_eq!(
3974/// u8::xxxx_add_yyyy_to_zzzz(0x78, 0x9a, 0xbc, 0xde, 0xfe, 0xdc, 0xba, 0x98),
3975/// (0x77, 0x77, 0x77, 0x76)
3976/// );
3977/// ```
3978pub mod xxxx_add_yyyy_to_zzzz;