1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
//! `puremp` — arbitrary-precision arithmetic written entirely in Rust, depending
//! on no foreign code.
//!
//! It provides a family of numeric types, built bottom-up:
//!
//! 1. **Integers** — unsigned [`Nat`] and signed [`Int`], the workhorse layer
//! that carries the hard limb-level algorithms (multiplication, division,
//! GCD, modular arithmetic, …). Enabled by the `int` feature.
//! 2. **Rationals** — [`Rational`], exact `p/q` fractions kept in lowest terms;
//! plus [`InfRational`], the same extended with `±∞`/`NaN`. `rational` feature.
//! 3. **Dyadics** — [`Dyadic`], exact `n·2^-k` binary fractions. `dyadic` feature.
//! 4. **Floats** — [`Float`], binary floating-point with a caller-chosen
//! precision and directed [`RoundingMode`], aiming at MPFR-class correct
//! rounding, plus [`FixedFloat`], a fixed-precision wrapper with operators.
//! `float` feature.
//!
//! `puremp` is usable as a Rust library, a C library (the `ffi` feature; see
//! `include/puremp.h`), and a standalone command-line calculator (the `cli`
//! feature; the `puremp` binary).
//!
//! This is a clean-room implementation: it is MIT-licensed and its algorithms
//! are drawn from the open literature, never from GMP/MPFR source. See
//! `ROADMAP.md` for the design, the algorithm references, and the milestone
//! plan.
//!
//! # Example
//!
//! ```
//! use puremp::{Int, Rational};
//!
//! // Arbitrary-precision integers.
//! let big = Int::from(2).pow(128);
//! assert_eq!(big.to_string(), "340282366920938463463374607431768211456");
//! assert_eq!(Int::from(1071).gcd(&Int::from(462)).to_string(), "21");
//! assert_eq!(Int::from(2).modpow(&Int::from(10), &Int::from(1000)).to_string(), "24");
//!
//! // Exact rationals, always in lowest terms.
//! let third = Rational::new(Int::from(1), Int::from(3));
//! let sum = &(&third + &third) + &third;
//! assert_eq!(sum.to_string(), "1");
//! ```
//!
//! # `no_std`
//!
//! The crate is `#![no_std]` at its core. Arbitrary-precision types are
//! heap-backed, so they need the `alloc` crate; the `alloc` feature (implied by
//! every type layer) pulls it in. The `std` feature (enabled by default) adds
//! the pieces that genuinely need the operating system — the CLI, `std::error`
//! integration, and system I/O. Build with `--no-default-features` for a bare
//! `no_std` target.
extern crate alloc;
extern crate std;
pub use ;
pub use ;
pub use ;
pub use RandomSource;
pub use InfRational;
pub use Rational;
pub use Dyadic;
pub use FixedFloat;
pub use ;
/// The crate version string (`CARGO_PKG_VERSION`), exposed for the C ABI and CLI.
pub const VERSION: &str = env!;