# Welcome to gmpy2's documentation!

gmpy2 is a C-coded Python extension module that supports multiple-precision arithmetic. It is the successor to the original gmpy module (supported only the GMP library). gmpy2 adds support for the MPFR (correctly rounded real floating-point arithmetic) and MPC (correctly rounded complex floating-point arithmetic) libraries.

The following libraries are supported:

- GMP for integer and rational arithmetic (https://gmplib.org)

- MPFR (https://www.mpfr.org)

- MPC (https://www.multiprecision.org/mpc/)

- Generalized Lucas sequences and primality tests are based on the following code:

  > - mpz_lucas: https://sourceforge.net/projects/mpzlucas/

  > - mpz_prp: https://sourceforge.net/projects/mpzprp/

## Contents

- Overview
- Installation
  - From Sources
- Tutorial
- Integers
  - mpz type
  - mpz Functions
- Integers (Advanced topics)
  - The xmpz type
  - Advanced Number Theory Functions
- Rationals
  - mpq type
  - mpq Functions
- Contexts
  - Context Type
  - Context Functions
- Exceptions
  - `RangeError`
  - `InexactResultError`
  - `OverflowResultError`
  - `UnderflowResultError`
  - `InvalidOperationError`
  - `DivisionByZeroError`
- Multiple-precision Reals
  - mpfr Type
  - mpfr Functions
- Multiple-precision Complex
  - mpc Type
  - mpc Functions
- Generic Functions
  - `add()`
  - `div()`
  - `mul()`
  - `sub()`
  - `square()`
  - `f2q()`
  - `fma()`
  - `fms()`
  - `cmp_abs()`
- Miscellaneous Functions
  - `digits()`
  - `from_binary()`
  - `license()`
  - `mp_limbsize()`
  - `mp_version()`
  - `mpc_version()`
  - `mpfr_version()`
  - `random_state()`
  - `to_binary()`
  - `version()`
- Cython usage
  - Initialization
  - Types
  - Object creation
  - Access to the underlying C type
  - Compilation
- Conversion Methods
  - Arithmetic operations
- Release Notes
  - Changes in gmpy2 2.2.1
  - Changes in gmpy2 2.2.0
  - Changes in gmpy2 2.1.5
  - Changes in gmpy2 2.1.4
  - Changes in gmpy2 2.1.3
  - Changes in gmpy2 2.1.2
  - Changes in gmpy2 2.1.1
  - Changes in gmpy2 2.1.0
  - Changes in gmpy2 2.1.0rc2
  - Changes in gmpy2 2.1.0rc1
  - Changes in gmpy2 2.1.0b6
  - Changes in gmpy2 2.1.0b5
  - Changes in gmpy2 2.1.0b4
  - Changes in gmpy2 2.1.0b3
  - Changes in gmpy2 2.1.0b2
  - Changes in gmpy2 2.1.0b1
  - Changes in gmpy2 2.1.a05
  - Changes in gmpy2 2.1.0a4
  - Changes in gmpy2 2.1.0a3
  - Changes in gmpy2 2.1.0a2
  - Changes in gmpy2 2.1.0a1
  - Changes in gmpy2 2.0.4
  - Changes in gmpy2 2.0.3
  - Changes in gmpy2 2.0.2
  - Changes in gmpy2 2.0.1
  - Changes in gmpy2 2.0.0
  - Known issues in gmpy2 2.0.0
  - Changes in gmpy2 2.0.0b4
  - Known issues in gmpy2 2.0.0b4
  - Changes in gmpy2 2.0.0b3
  - Changes in gmpy2 2.0.0b2
  - Changes in gmpy2 2.0.0b1
  - Changes in gmpy 1.11
  - Changes in gmpy 1.10
  - Changes in gmpy 1.04
  - Changes in gmpy 1.03
  - Changes in gmpy 1.02
  - Changes in gmpy 1.01
  - Changes in gmpy 1.0
  - Changes in gmpy 0.9
  - Changes in gmpy 0.8
  - Changes in gmpy 0.7
  - Changes in gmpy 0.6
  - Changes in gmpy 0.5
  - Changes in gmpy 0.4
  - Changes in gmpy 0.3
  - Changes in gmpy 0.2
  - Changes in gmpy 0.1

# Indices and tables

- Index

- Search Page