Expand description
pure-Rust, no-unsafe, no_std, no_alloc arbitrary-precision signed integer (Mpz),
faithful to GMP’s mpz_* operations.
§Guarantees
- Zero
unsafecode —#![forbid(unsafe_code)]enforced at compile time. no_std— no standard library dependency; onlycore.no_alloc— zero heap allocations in the library itself. Fixed-capacity limb storage ([u64; 8], 512 bits ≈ 154 decimal digits). Operations that would exceed capacity returnCapacityError.
§Representation
Sign–magnitude. mag[0..len] is little-endian base-2⁶⁴ limbs with no trailing zero
(so zero is len == 0 && sign == 0).
Structs§
- Capacity
Error - The operation would exceed the fixed limb capacity.
- Mpz
- Arbitrary-precision signed integer with fixed capacity (no heap allocation).
Enums§
- Endian
- Byte order for
Mpz::try_importandMpz::export_buf. - Parse
Error - An error occurred while parsing a decimal string.
Constants§
- LIMBS
- Number of limbs (public alias for
MPZ_MAX_LIMBS). - MAX_
BITS - Maximum bit width (512 bits). Useful for static analysers.
- MAX_
DECIMAL_ DIGITS - Maximum number of decimal digits representable (floor(log10(2^512)) = floor(512 * log10(2)) ≈ 154).
- MPZ_
MAX_ LIMBS - Maximum number of 64-bit limbs. 8 limbs = 512 bits ≈ 154 decimal digits.