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