Skip to main content

Crate gmp_rs

Crate gmp_rs 

Source
Expand description

pure-Rust, no-unsafe, no_std, no_alloc arbitrary-precision signed integer (Mpz), faithful to GMP’s mpz_* operations.

§Guarantees

  • Zero unsafe code — #![forbid(unsafe_code)] enforced at compile time.
  • no_std — no standard library dependency; only core.
  • 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 return CapacityError.

§Representation

Sign–magnitude. mag[0..len] is little-endian base-2⁶⁴ limbs with no trailing zero (so zero is len == 0 && sign == 0).

Structs§

CapacityError
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_import and Mpz::export_buf.
ParseError
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.