Skip to main content

malachite_float/arithmetic/
mod.rs

1// Copyright © 2026 Mikhail Hogrefe
2//
3// This file is part of Malachite.
4//
5// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU
6// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version
7// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.
8
9/// Absolute value of [`Float`](super::Float)s.
10pub mod abs;
11/// Addition of [`Float`](super::Float)s, and of [`Float`](super::Float)s with
12/// [`Rational`](malachite_q::Rational)s.
13pub mod add;
14/// Taking the AGM (arithmetic-geometric mean) of two [`Float`](super::Float)s, and of
15/// [`Float`](super::Float)s with [`Rational`](malachite_q::Rational)s.
16pub mod agm;
17/// Division of [`Float`](super::Float)s, of [`Float`](super::Float)s by
18/// [`Rational`](malachite_q::Rational)s, and of [`Rational`](malachite_q::Rational)s by
19/// [`Float`](super::Float)s.
20pub mod div;
21/// An implementation of [`IsPowerOf2`](malachite_base::num::arithmetic::traits::IsPowerOf2), a
22/// trait for determining whether a number is an integer power of 2.
23pub mod is_power_of_2;
24/// [`Ln`](malachite_base::num::arithmetic::traits::Ln) and
25/// [`LnAssign`](malachite_base::num::arithmetic::traits::LnAssign), traits for computing the
26/// natural logarithm of [`Float`](super::Float)s.
27pub mod ln;
28/// [`Ln1PlusX`](malachite_base::num::arithmetic::traits::Ln1PlusX) and
29/// [`Ln1PlusXAssign`](malachite_base::num::arithmetic::traits::Ln1PlusXAssign), traits for
30/// computing $\ln(1+x)$ for [`Float`](super::Float)s.
31pub mod ln_1_plus_x;
32/// [`LogBase`](malachite_base::num::arithmetic::traits::LogBase) and
33/// [`LogBaseAssign`](malachite_base::num::arithmetic::traits::LogBaseAssign), traits for computing
34/// the base-$b$ logarithm of [`Float`](super::Float)s for an arbitrary integer base $b>1$.
35pub mod log_base;
36/// [`LogBase10`](malachite_base::num::arithmetic::traits::LogBase10) and
37/// [`LogBase10Assign`](malachite_base::num::arithmetic::traits::LogBase10Assign), traits for
38/// computing the base-10 logarithm of [`Float`](super::Float)s.
39pub mod log_base_10;
40/// [`LogBase10Of1PlusX`](malachite_base::num::arithmetic::traits::LogBase10Of1PlusX) and
41/// [`LogBase10Of1PlusXAssign`](malachite_base::num::arithmetic::traits::LogBase10Of1PlusXAssign),
42/// traits for computing $\log_{10}(1+x)$ of [`Float`](super::Float)s.
43pub mod log_base_10_1_plus_x;
44/// [`LogBaseOf1PlusX`](malachite_base::num::arithmetic::traits::LogBaseOf1PlusX) and
45/// [`LogBaseOf1PlusXAssign`](malachite_base::num::arithmetic::traits::LogBaseOf1PlusXAssign),
46/// traits for computing $\log_b(1+x)$ of [`Float`](super::Float)s for an arbitrary integer base
47/// $b>1$.
48pub mod log_base_1_plus_x;
49/// [`LogBase2`](malachite_base::num::arithmetic::traits::LogBase2) and
50/// [`LogBase2Assign`](malachite_base::num::arithmetic::traits::LogBase2Assign), traits for
51/// computing the base-2 logarithm of [`Float`](super::Float)s.
52pub mod log_base_2;
53/// [`LogBase2Of1PlusX`](malachite_base::num::arithmetic::traits::LogBase2Of1PlusX) and
54/// [`LogBase2Of1PlusXAssign`](malachite_base::num::arithmetic::traits::LogBase2Of1PlusXAssign),
55/// traits for computing $\log_2(1+x)$ for [`Float`](super::Float)s.
56pub mod log_base_2_1_plus_x;
57/// [`LogBase`](malachite_base::num::arithmetic::traits::LogBase) and
58/// [`LogBaseAssign`](malachite_base::num::arithmetic::traits::LogBaseAssign), implemented for a
59/// [`Float`](super::Float) base, for computing $\log_b x$ of a [`Float`](super::Float) with an
60/// arbitrary [`Float`](super::Float) base.
61pub mod log_base_float_base;
62/// [`LogBaseOf1PlusX`](malachite_base::num::arithmetic::traits::LogBaseOf1PlusX) and
63/// [`LogBaseOf1PlusXAssign`](malachite_base::num::arithmetic::traits::LogBaseOf1PlusXAssign),
64/// implemented for a [`Float`](super::Float) base, for computing $\log_b(1+x)$ of a
65/// [`Float`](super::Float) with an arbitrary [`Float`](super::Float) base.
66pub mod log_base_float_base_1_plus_x;
67/// [`LogBasePowerOf2`](malachite_base::num::arithmetic::traits::LogBasePowerOf2) and
68/// [`LogBasePowerOf2Assign`](malachite_base::num::arithmetic::traits::LogBasePowerOf2Assign),
69/// traits for computing $\log_{2^k} x$ for [`Float`](super::Float)s.
70pub mod log_base_power_of_2;
71/// [`LogBasePowerOf2Of1PlusX`](malachite_base::num::arithmetic::traits::LogBasePowerOf2Of1PlusX)
72/// and
73/// [`LogBasePowerOf2Of1PlusXAssign`](malachite_base::num::arithmetic::traits::LogBasePowerOf2Of1PlusXAssign),
74/// traits for computing $\log_{2^k}(1+x)$ for [`Float`](super::Float)s.
75pub mod log_base_power_of_2_1_plus_x;
76/// [`LogBase`](malachite_base::num::arithmetic::traits::LogBase) and
77/// [`LogBaseAssign`](malachite_base::num::arithmetic::traits::LogBaseAssign), implemented for a
78/// [`Rational`](malachite_q::Rational) base, for computing $\log_b x$ of a [`Float`](super::Float)
79/// with an arbitrary rational base $b>1$.
80pub mod log_base_rational_base;
81/// [`LogBaseOf1PlusX`](malachite_base::num::arithmetic::traits::LogBaseOf1PlusX) and
82/// [`LogBaseOf1PlusXAssign`](malachite_base::num::arithmetic::traits::LogBaseOf1PlusXAssign),
83/// implemented for a [`Rational`](malachite_q::Rational) base, for computing $\log_b(1+x)$ of a
84/// [`Float`](super::Float) with an arbitrary rational base $b>1$.
85pub mod log_base_rational_base_1_plus_x;
86/// Functions for computing $\log_b x$ of a [`Rational`](malachite_q::Rational) $x$ with an
87/// arbitrary [`Float`](super::Float) base, returning a [`Float`](super::Float).
88pub mod log_base_rational_float_base;
89/// Functions for computing $\log_b x$ of a [`Rational`](malachite_q::Rational) $x$ with an
90/// arbitrary [`Rational`](malachite_q::Rational) base $b>1$, returning a [`Float`](super::Float).
91pub mod log_base_rational_rational_base;
92/// Multiplication of [`Float`](super::Float)s, and of [`Float`](super::Float)s with
93/// [`Rational`](malachite_q::Rational)s.
94pub mod mul;
95/// Negation of [`Float`](super::Float)s.
96pub mod neg;
97/// Implementations of [`PowerOf2`](malachite_base::num::arithmetic::traits::PowerOf2), a trait for
98/// computing a power of 2.
99pub mod power_of_2;
100/// Implementations of [`Reciprocal`](malachite_base::num::arithmetic::traits::Reciprocal) and
101/// [`ReciprocalAssign`](malachite_base::num::arithmetic::traits::ReciprocalAssign), traits for
102/// computing the reciprocal of a number.
103pub mod reciprocal;
104/// [`ReciprocalSqrt`](malachite_base::num::arithmetic::traits::ReciprocalSqrt) and
105/// [`ReciprocalSqrtAssign`](malachite_base::num::arithmetic::traits::ReciprocalSqrtAssign), traits
106/// for computing the reciprocal of the square root of [`Float`](super::Float)s.
107pub mod reciprocal_sqrt;
108pub(crate) mod round_near_x;
109/// Left-shifting a [`Float`](super::Float) (multiplying it by a power of 2).
110///
111/// # shl
112/// ```
113/// use malachite_base::num::basic::traits::{Infinity, Zero};
114/// use malachite_float::Float;
115///
116/// assert_eq!(Float::ZERO << 10, 0);
117/// assert_eq!(Float::INFINITY << 10, Float::INFINITY);
118/// assert_eq!(
119///     (Float::from(std::f64::consts::PI) << 10u8).to_string(),
120///     "3216.990877275948"
121/// );
122/// assert_eq!(
123///     (Float::from(std::f64::consts::PI) << -10i8).to_string(),
124///     "0.003067961575771282"
125/// );
126///
127/// assert_eq!(&Float::ZERO << 10, 0);
128/// assert_eq!(&Float::INFINITY << 10, Float::INFINITY);
129/// assert_eq!(
130///     (&Float::from(std::f64::consts::PI) << 10u8).to_string(),
131///     "3216.990877275948"
132/// );
133/// assert_eq!(
134///     (&Float::from(std::f64::consts::PI) << -10i8).to_string(),
135///     "0.003067961575771282"
136/// );
137/// ```
138///
139/// # shl_assign
140/// ```
141/// use malachite_base::num::basic::traits::{Infinity, Zero};
142/// use malachite_float::Float;
143///
144/// let mut x = Float::ZERO;
145/// x <<= 10;
146/// assert_eq!(x, 0);
147///
148/// let mut x = Float::INFINITY;
149/// x <<= 10;
150/// assert_eq!(x, Float::INFINITY);
151///
152/// let mut x = Float::from(std::f64::consts::PI);
153/// x <<= 10;
154/// assert_eq!(x.to_string(), "3216.990877275948");
155///
156/// let mut x = Float::from(std::f64::consts::PI);
157/// x <<= -10;
158/// assert_eq!(x.to_string(), "0.003067961575771282");
159/// ```
160pub mod shl;
161/// Implementations of [`ShlRound`](malachite_base::num::arithmetic::traits::ShlRound) and
162/// [`ShlRoundAssign`](malachite_base::num::arithmetic::traits::ShlRoundAssign), traits for
163/// multiplying a number by a power of 2 and rounding according to a specified
164/// [`RoundingMode`](malachite_base::rounding_modes::RoundingMode). For [`Float`](super::Float)s,
165/// rounding is only necessary in the cases of overflow and underflow.
166///
167/// # shl_prec_round
168/// ```
169/// use malachite_base::rounding_modes::RoundingMode::*;
170/// use malachite_float::Float;
171/// use std::cmp::Ordering::*;
172///
173/// let (shifted, o) = Float::from(std::f64::consts::PI).shl_prec_round(10u8, 10, Nearest);
174/// assert_eq!(shifted.to_string(), "3216.0");
175/// assert_eq!(o, Less);
176///
177/// let (shifted, o) = Float::from(std::f64::consts::PI).shl_prec_round(-10i8, 10, Nearest);
178/// assert_eq!(shifted.to_string(), "0.003067");
179/// assert_eq!(o, Less);
180///
181/// let (shifted, o) = Float::from(std::f64::consts::PI).shl_prec_round(u32::MAX, 10, Floor);
182/// assert_eq!(shifted.to_string(), "too_big");
183/// assert_eq!(o, Less);
184///
185/// let (shifted, o) = Float::from(std::f64::consts::PI).shl_prec_round(u32::MAX, 10, Ceiling);
186/// assert_eq!(shifted.to_string(), "Infinity");
187/// assert_eq!(o, Greater);
188///
189/// let (shifted, o) = Float::from(std::f64::consts::PI).shl_prec_round_ref(10u8, 10, Nearest);
190/// assert_eq!(shifted.to_string(), "3216.0");
191/// assert_eq!(o, Less);
192///
193/// let (shifted, o) = Float::from(std::f64::consts::PI).shl_prec_round_ref(-10i8, 10, Nearest);
194/// assert_eq!(shifted.to_string(), "0.003067");
195/// assert_eq!(o, Less);
196///
197/// let (shifted, o) = Float::from(std::f64::consts::PI).shl_prec_round_ref(u32::MAX, 10, Floor);
198/// assert_eq!(shifted.to_string(), "too_big");
199/// assert_eq!(o, Less);
200///
201/// let (shifted, o) = Float::from(std::f64::consts::PI).shl_prec_round_ref(u32::MAX, 10, Ceiling);
202/// assert_eq!(shifted.to_string(), "Infinity");
203/// assert_eq!(o, Greater);
204/// ```
205///
206/// # shl_prec_round_assign
207/// ```
208/// use malachite_base::rounding_modes::RoundingMode::*;
209/// use malachite_float::Float;
210/// use std::cmp::Ordering::*;
211///
212/// let mut x = Float::from(std::f64::consts::PI);
213/// assert_eq!(x.shl_prec_round_assign(10u8, 10, Nearest), Less);
214/// assert_eq!(x.to_string(), "3216.0");
215///
216/// let mut x = Float::from(std::f64::consts::PI);
217/// assert_eq!(x.shl_prec_round_assign(-10i8, 10, Nearest), Less);
218/// assert_eq!(x.to_string(), "0.003067");
219///
220/// let mut x = Float::from(std::f64::consts::PI);
221/// assert_eq!(x.shl_prec_round_assign(u32::MAX, 10, Floor), Less);
222/// assert_eq!(x.to_string(), "too_big");
223///
224/// let mut x = Float::from(std::f64::consts::PI);
225/// assert_eq!(x.shl_prec_round_assign(u32::MAX, 10, Ceiling), Greater);
226/// assert_eq!(x.to_string(), "Infinity");
227/// ```
228///
229/// # shl_prec
230/// ```
231/// use malachite_float::Float;
232/// use std::cmp::Ordering::*;
233///
234/// let (shifted, o) = Float::from(std::f64::consts::PI).shl_prec(10u8, 10);
235/// assert_eq!(shifted.to_string(), "3216.0");
236/// assert_eq!(o, Less);
237///
238/// let (shifted, o) = Float::from(std::f64::consts::PI).shl_prec(-10i8, 10);
239/// assert_eq!(shifted.to_string(), "0.003067");
240/// assert_eq!(o, Less);
241///
242/// let (shifted, o) = Float::from(std::f64::consts::PI).shl_prec(u32::MAX, 10);
243/// assert_eq!(shifted.to_string(), "Infinity");
244/// assert_eq!(o, Greater);
245///
246/// let (shifted, o) = Float::from(std::f64::consts::PI).shl_prec_ref(10u8, 10);
247/// assert_eq!(shifted.to_string(), "3216.0");
248/// assert_eq!(o, Less);
249///
250/// let (shifted, o) = Float::from(std::f64::consts::PI).shl_prec_ref(-10i8, 10);
251/// assert_eq!(shifted.to_string(), "0.003067");
252/// assert_eq!(o, Less);
253///
254/// let (shifted, o) = Float::from(std::f64::consts::PI).shl_prec_ref(u32::MAX, 10);
255/// assert_eq!(shifted.to_string(), "Infinity");
256/// assert_eq!(o, Greater);
257/// ```
258///
259/// # shl_prec_assign
260/// ```
261/// use malachite_float::Float;
262/// use std::cmp::Ordering::*;
263///
264/// let mut x = Float::from(std::f64::consts::PI);
265/// assert_eq!(x.shl_prec_assign(10u8, 10), Less);
266/// assert_eq!(x.to_string(), "3216.0");
267///
268/// let mut x = Float::from(std::f64::consts::PI);
269/// assert_eq!(x.shl_prec_assign(-10i8, 10), Less);
270/// assert_eq!(x.to_string(), "0.003067");
271///
272/// let mut x = Float::from(std::f64::consts::PI);
273/// assert_eq!(x.shl_prec_assign(u32::MAX, 10), Greater);
274/// assert_eq!(x.to_string(), "Infinity");
275/// ```
276///
277/// # shl_round
278/// ```
279/// use malachite_base::num::arithmetic::traits::ShlRound;
280/// use malachite_base::rounding_modes::RoundingMode::*;
281/// use malachite_float::Float;
282/// use std::cmp::Ordering::*;
283///
284/// let (shifted, o) = Float::from(std::f64::consts::PI).shl_round(10u8, Nearest);
285/// assert_eq!(shifted.to_string(), "3216.990877275948");
286/// assert_eq!(o, Equal);
287///
288/// let (shifted, o) = Float::from(std::f64::consts::PI).shl_round(-10i8, Nearest);
289/// assert_eq!(shifted.to_string(), "0.003067961575771282");
290/// assert_eq!(o, Equal);
291///
292/// let (shifted, o) = Float::from(std::f64::consts::PI).shl_round(u32::MAX, Floor);
293/// assert_eq!(shifted.to_string(), "too_big");
294/// assert_eq!(o, Less);
295///
296/// let (shifted, o) = Float::from(std::f64::consts::PI).shl_round(u32::MAX, Ceiling);
297/// assert_eq!(shifted.to_string(), "Infinity");
298/// assert_eq!(o, Greater);
299///
300/// let (shifted, o) = (&Float::from(std::f64::consts::PI)).shl_round(10u8, Nearest);
301/// assert_eq!(shifted.to_string(), "3216.990877275948");
302/// assert_eq!(o, Equal);
303///
304/// let (shifted, o) = (&Float::from(std::f64::consts::PI)).shl_round(-10i8, Nearest);
305/// assert_eq!(shifted.to_string(), "0.003067961575771282");
306/// assert_eq!(o, Equal);
307///
308/// let (shifted, o) = (&Float::from(std::f64::consts::PI)).shl_round(u32::MAX, Floor);
309/// assert_eq!(shifted.to_string(), "too_big");
310/// assert_eq!(o, Less);
311///
312/// let (shifted, o) = (&Float::from(std::f64::consts::PI)).shl_round(u32::MAX, Ceiling);
313/// assert_eq!(shifted.to_string(), "Infinity");
314/// assert_eq!(o, Greater);
315/// ```
316///
317/// # shl_round_assign
318/// ```
319/// use malachite_base::num::arithmetic::traits::ShlRoundAssign;
320/// use malachite_base::rounding_modes::RoundingMode::*;
321/// use malachite_float::Float;
322/// use std::cmp::Ordering::*;
323///
324/// let mut x = Float::from(std::f64::consts::PI);
325/// assert_eq!(x.shl_round_assign(10u8, Nearest), Equal);
326/// assert_eq!(x.to_string(), "3216.990877275948");
327///
328/// let mut x = Float::from(std::f64::consts::PI);
329/// assert_eq!(x.shl_round_assign(-10i8, Nearest), Equal);
330/// assert_eq!(x.to_string(), "0.003067961575771282");
331///
332/// let mut x = Float::from(std::f64::consts::PI);
333/// assert_eq!(x.shl_round_assign(u32::MAX, Floor), Less);
334/// assert_eq!(x.to_string(), "too_big");
335///
336/// let mut x = Float::from(std::f64::consts::PI);
337/// assert_eq!(x.shl_round_assign(u32::MAX, Ceiling), Greater);
338/// assert_eq!(x.to_string(), "Infinity");
339/// ```
340pub mod shl_round;
341/// Right-shifting a [`Float`](super::Float) (dividing it by a power of 2).
342///
343/// # shr
344/// ```
345/// use malachite_base::num::basic::traits::{Infinity, Zero};
346/// use malachite_float::Float;
347///
348/// assert_eq!(Float::ZERO >> 10, 0);
349/// assert_eq!(Float::INFINITY >> 10, Float::INFINITY);
350/// assert_eq!(
351///     (Float::from(std::f64::consts::PI) >> 10u8).to_string(),
352///     "0.003067961575771282"
353/// );
354/// assert_eq!(
355///     (Float::from(std::f64::consts::PI) >> -10i8).to_string(),
356///     "3216.990877275948"
357/// );
358///
359/// assert_eq!(&Float::ZERO >> 10, 0);
360/// assert_eq!(&Float::INFINITY >> 10, Float::INFINITY);
361/// assert_eq!(
362///     (&Float::from(std::f64::consts::PI) >> 10u8).to_string(),
363///     "0.003067961575771282"
364/// );
365/// assert_eq!(
366///     (&Float::from(std::f64::consts::PI) >> -10i8).to_string(),
367///     "3216.990877275948"
368/// );
369/// ```
370///
371/// # shr_assign
372/// ```
373/// use malachite_base::num::basic::traits::{Infinity, Zero};
374/// use malachite_float::Float;
375///
376/// let mut x = Float::ZERO;
377/// x >>= 10;
378/// assert_eq!(x, 0);
379///
380/// let mut x = Float::INFINITY;
381/// x >>= 10;
382/// assert_eq!(x, Float::INFINITY);
383///
384/// let mut x = Float::from(std::f64::consts::PI);
385/// x >>= 10;
386/// assert_eq!(x.to_string(), "0.003067961575771282");
387///
388/// let mut x = Float::from(std::f64::consts::PI);
389/// x >>= -10;
390/// assert_eq!(x.to_string(), "3216.990877275948");
391/// ```
392pub mod shr;
393/// Implementations of [`ShlRound`](malachite_base::num::arithmetic::traits::ShrRound) and
394/// [`ShrRoundAssign`](malachite_base::num::arithmetic::traits::ShrRoundAssign), traits for dividing
395/// a number by a power of 2 and rounding according to a specified
396/// [`RoundingMode`](malachite_base::rounding_modes::RoundingMode). For [`Float`](super::Float)s,
397/// rounding is only necessary in the cases of overflow and underflow.
398///
399/// # shr_prec_round
400/// ```
401/// use malachite_base::rounding_modes::RoundingMode::*;
402/// use malachite_float::Float;
403/// use std::cmp::Ordering::*;
404///
405/// let (shifted, o) = Float::from(std::f64::consts::PI).shr_prec_round(10u8, 10, Nearest);
406/// assert_eq!(shifted.to_string(), "0.003067");
407/// assert_eq!(o, Less);
408///
409/// let (shifted, o) = Float::from(std::f64::consts::PI).shr_prec_round(-10i8, 10, Nearest);
410/// assert_eq!(shifted.to_string(), "3216.0");
411/// assert_eq!(o, Less);
412///
413/// let (shifted, o) = Float::from(std::f64::consts::PI).shr_prec_round(u32::MAX, 10, Floor);
414/// assert_eq!(shifted.to_string(), "0.0");
415/// assert_eq!(o, Less);
416///
417/// let (shifted, o) = Float::from(std::f64::consts::PI).shr_prec_round(u32::MAX, 10, Ceiling);
418/// assert_eq!(shifted.to_string(), "too_small");
419/// assert_eq!(o, Greater);
420///
421/// let (shifted, o) = Float::from(std::f64::consts::PI).shr_prec_round_ref(10u8, 10, Nearest);
422/// assert_eq!(shifted.to_string(), "0.003067");
423/// assert_eq!(o, Less);
424///
425/// let (shifted, o) = Float::from(std::f64::consts::PI).shr_prec_round_ref(-10i8, 10, Nearest);
426/// assert_eq!(shifted.to_string(), "3216.0");
427/// assert_eq!(o, Less);
428///
429/// let (shifted, o) = Float::from(std::f64::consts::PI).shr_prec_round_ref(u32::MAX, 10, Floor);
430/// assert_eq!(shifted.to_string(), "0.0");
431/// assert_eq!(o, Less);
432///
433/// let (shifted, o) = Float::from(std::f64::consts::PI).shr_prec_round_ref(u32::MAX, 10, Ceiling);
434/// assert_eq!(shifted.to_string(), "too_small");
435/// assert_eq!(o, Greater);
436/// ```
437///
438/// # shr_prec_round_assign
439/// ```
440/// use malachite_base::rounding_modes::RoundingMode::*;
441/// use malachite_float::Float;
442/// use std::cmp::Ordering::*;
443///
444/// let mut x = Float::from(std::f64::consts::PI);
445/// assert_eq!(x.shr_prec_round_assign(10u8, 10, Nearest), Less);
446/// assert_eq!(x.to_string(), "0.003067");
447///
448/// let mut x = Float::from(std::f64::consts::PI);
449/// assert_eq!(x.shr_prec_round_assign(-10i8, 10, Nearest), Less);
450/// assert_eq!(x.to_string(), "3216.0");
451///
452/// let mut x = Float::from(std::f64::consts::PI);
453/// assert_eq!(x.shr_prec_round_assign(u32::MAX, 10, Floor), Less);
454/// assert_eq!(x.to_string(), "0.0");
455///
456/// let mut x = Float::from(std::f64::consts::PI);
457/// assert_eq!(x.shr_prec_round_assign(u32::MAX, 10, Ceiling), Greater);
458/// assert_eq!(x.to_string(), "too_small");
459/// ```
460///
461/// # shr_prec
462/// ```
463/// use malachite_float::Float;
464/// use std::cmp::Ordering::*;
465///
466/// let (shifted, o) = Float::from(std::f64::consts::PI).shr_prec(10u8, 10);
467/// assert_eq!(shifted.to_string(), "0.003067");
468/// assert_eq!(o, Less);
469///
470/// let (shifted, o) = Float::from(std::f64::consts::PI).shr_prec(-10i8, 10);
471/// assert_eq!(shifted.to_string(), "3216.0");
472/// assert_eq!(o, Less);
473///
474/// let (shifted, o) = Float::from(std::f64::consts::PI).shr_prec(u32::MAX, 10);
475/// assert_eq!(shifted.to_string(), "0.0");
476/// assert_eq!(o, Less);
477///
478/// let (shifted, o) = Float::from(std::f64::consts::PI).shr_prec_ref(10u8, 10);
479/// assert_eq!(shifted.to_string(), "0.003067");
480/// assert_eq!(o, Less);
481///
482/// let (shifted, o) = Float::from(std::f64::consts::PI).shr_prec_ref(-10i8, 10);
483/// assert_eq!(shifted.to_string(), "3216.0");
484/// assert_eq!(o, Less);
485///
486/// let (shifted, o) = Float::from(std::f64::consts::PI).shr_prec_ref(u32::MAX, 10);
487/// assert_eq!(shifted.to_string(), "0.0");
488/// assert_eq!(o, Less);
489/// ```
490///
491/// # shr_prec_assign
492/// ```
493/// use malachite_float::Float;
494/// use std::cmp::Ordering::*;
495///
496/// let mut x = Float::from(std::f64::consts::PI);
497/// assert_eq!(x.shr_prec_assign(10u8, 10), Less);
498/// assert_eq!(x.to_string(), "0.003067");
499///
500/// let mut x = Float::from(std::f64::consts::PI);
501/// assert_eq!(x.shr_prec_assign(-10i8, 10), Less);
502/// assert_eq!(x.to_string(), "3216.0");
503///
504/// let mut x = Float::from(std::f64::consts::PI);
505/// assert_eq!(x.shr_prec_assign(u32::MAX, 10), Less);
506/// assert_eq!(x.to_string(), "0.0");
507/// ```
508///
509/// # shr_round
510/// ```
511/// use malachite_base::num::arithmetic::traits::ShrRound;
512/// use malachite_base::rounding_modes::RoundingMode::*;
513/// use malachite_float::Float;
514/// use std::cmp::Ordering::*;
515///
516/// let (shifted, o) = Float::from(std::f64::consts::PI).shr_round(10u8, Nearest);
517/// assert_eq!(shifted.to_string(), "0.003067961575771282");
518/// assert_eq!(o, Equal);
519///
520/// let (shifted, o) = Float::from(std::f64::consts::PI).shr_round(-10i8, Nearest);
521/// assert_eq!(shifted.to_string(), "3216.990877275948");
522/// assert_eq!(o, Equal);
523///
524/// let (shifted, o) = Float::from(std::f64::consts::PI).shr_round(u32::MAX, Floor);
525/// assert_eq!(shifted.to_string(), "0.0");
526/// assert_eq!(o, Less);
527///
528/// let (shifted, o) = Float::from(std::f64::consts::PI).shr_round(u32::MAX, Ceiling);
529/// assert_eq!(shifted.to_string(), "too_small");
530/// assert_eq!(o, Greater);
531///
532/// let (shifted, o) = (&Float::from(std::f64::consts::PI)).shr_round(10u8, Nearest);
533/// assert_eq!(shifted.to_string(), "0.003067961575771282");
534/// assert_eq!(o, Equal);
535///
536/// let (shifted, o) = (&Float::from(std::f64::consts::PI)).shr_round(-10i8, Nearest);
537/// assert_eq!(shifted.to_string(), "3216.990877275948");
538/// assert_eq!(o, Equal);
539///
540/// let (shifted, o) = (&Float::from(std::f64::consts::PI)).shr_round(u32::MAX, Floor);
541/// assert_eq!(shifted.to_string(), "0.0");
542/// assert_eq!(o, Less);
543///
544/// let (shifted, o) = (&Float::from(std::f64::consts::PI)).shr_round(u32::MAX, Ceiling);
545/// assert_eq!(shifted.to_string(), "too_small");
546/// assert_eq!(o, Greater);
547/// ```
548///
549/// # shr_round_assign
550/// ```
551/// use malachite_base::num::arithmetic::traits::ShrRoundAssign;
552/// use malachite_base::rounding_modes::RoundingMode::*;
553/// use malachite_float::Float;
554/// use std::cmp::Ordering::*;
555///
556/// let mut x = Float::from(std::f64::consts::PI);
557/// assert_eq!(x.shr_round_assign(10u8, Nearest), Equal);
558/// assert_eq!(x.to_string(), "0.003067961575771282");
559///
560/// let mut x = Float::from(std::f64::consts::PI);
561/// assert_eq!(x.shr_round_assign(-10i8, Nearest), Equal);
562/// assert_eq!(x.to_string(), "3216.990877275948");
563///
564/// let mut x = Float::from(std::f64::consts::PI);
565/// assert_eq!(x.shr_round_assign(u32::MAX, Floor), Less);
566/// assert_eq!(x.to_string(), "0.0");
567///
568/// let mut x = Float::from(std::f64::consts::PI);
569/// assert_eq!(x.shr_round_assign(u32::MAX, Ceiling), Greater);
570/// assert_eq!(x.to_string(), "too_small");
571/// ```
572pub mod shr_round;
573/// An implementation of [`Sign`](malachite_base::num::arithmetic::traits::Sign), a trait for
574/// determining the sign of a number.
575pub mod sign;
576/// [`Sqrt`](malachite_base::num::arithmetic::traits::Sqrt) and
577/// [`SqrtAssign`](malachite_base::num::arithmetic::traits::SqrtAssign), traits for computing the
578/// square root of [`Float`](super::Float)s.
579pub mod sqrt;
580/// Squaring of [`Float`](super::Float)s.
581pub mod square;
582/// Subtraction of [`Float`](super::Float)s, of [`Float`](super::Float)s by
583/// [`Rational`](malachite_q::Rational)s, and of [`Rational`](malachite_q::Rational)s by
584/// [`Float`](super::Float)s.
585pub mod sub;