Home

MPIR

MPIR is a free, portable library for arbitrary-precision arithmetic, with a focus on integers and rational numbers. It originated as a fork of the GNU Multiple Precision Arithmetic Library (GMP) intended to maintain compatibility with GMP’s API while preserving independence and portability. MPIR provides data types for big integers and rational numbers and supports a wide range of operations, including addition, subtraction, multiplication, division, modular arithmetic, and conversion between representations. It is designed to be a drop-in replacement for GMP in many projects, enabling developers to compile against libmpir and link with mpz_t and mpq_t types with minimal changes.

The library emphasizes portability across architectures and operating systems and is implemented in C with attention

MPIR is maintained independently and has been adopted by software projects as an alternative to GMP in

to
performance.
MPIR
includes
multiple-precision
algorithms
such
as
FFT-based
multiplication
for
large
operands,
alongside
classical
methods
like
Karatsuba
and
Toom-Cook,
with
options
that
can
be
tuned
based
on
platform
capabilities.
It
provides
functionality
for
big
integers
and
rational
numbers
and
uses
GMP-compatible
naming
conventions
and
interfaces
to
facilitate
integration
with
existing
codebases.
certain
environments,
particularly
where
licensing,
maintenance,
or
compatibility
considerations
influence
choice.
Ongoing
development
consists
of
community
contributions
and
updates
to
API
and
ABI
compatibility
notes
to
assist
developers
who
consider
migrating
from
GMP.
MPIR
remains
a
reference
point
in
discussions
of
portable,
high-performance
arbitrary-precision
arithmetic
libraries.