# boostorg/multiprecision architecture

> Architecture diagram of the GitHub repository boostorg/multiprecision, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-11-10). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/boostorg/multiprecision
- Repository: https://github.com/boostorg/multiprecision

## Overview

Boost.Multiprecision is a header-only C++ library for extended-range integer, rational, floating-point, complex, and interval-style number types. A typical use configures a `number` type with a backend, performs arithmetic or mathematical operations, and consumes the resulting value through conversions or formatting. The README documents the generic interface and backend families; sampled source also shows benchmark components. Unsampled headers are represented at subsystem level, so their internal call relationships are not inferred.

Main entry points: [`include/boost/multiprecision/number.hpp`](https://github.com/boostorg/multiprecision/blob/develop/include/boost/multiprecision/number.hpp) (Number interface), [`performance/miller_rabin_performance.hpp`](https://github.com/boostorg/multiprecision/blob/develop/performance/miller_rabin_performance.hpp) (Miller–Rabin benchmark), [`include/boost/multiprecision/cpp_bin_float.hpp`](https://github.com/boostorg/multiprecision/blob/develop/include/boost/multiprecision/cpp_bin_float.hpp) (Binary floats), [`include/boost/multiprecision/cpp_int.hpp`](https://github.com/boostorg/multiprecision/blob/develop/include/boost/multiprecision/cpp_int.hpp) (Arbitrary integers)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_api["Generic Number API"]
  node_number["Number interface<br/>[number.hpp]"]
  node_concepts["Backend concepts"]
  node_etops["Expression operations<br/>[et_ops.hpp]"]
  node_defaultops["Default operations<br/>[default_ops.hpp]"]
end

subgraph group_native["Built-in Backends"]
  node_cppint["Arbitrary integers<br/>[cpp_int.hpp]"]
  node_decimal["Decimal floats<br/>[cpp_dec_float.hpp]"]
  node_binary["Binary floats<br/>[cpp_bin_float.hpp]"]
  node_complex["Complex numbers<br/>[cpp_complex.hpp]"]
  node_rational["Rational numbers"]
end

subgraph group_integrations["External Backends"]
  node_gmp["GMP backend<br/>[gmp.hpp]"]
  node_mpfr["MPFR backend<br/>[mpfr.hpp]"]
  node_mpc["MPC backend<br/>[mpc.hpp]"]
  node_tommath["TomMath backend<br/>[tommath.hpp]"]
end

subgraph group_math["Math and Interop"]
  node_special["Math functions<br/>[trig.hpp]"]
  node_random["Random support<br/>[random.hpp]"]
  node_miller["Primality testing<br/>[miller_rabin.hpp]"]
  node_format["Float formatting<br/>[io.hpp]"]
end

subgraph group_benchmarks["Performance Benchmarks"]
  node_arithbench["Arithmetic backend benchmark"]
  node_millerbench["Miller–Rabin benchmark"]
  node_dfbench["Decimal-float benchmark"]
  node_dfbenchh["Benchmark support"]
  node_sfbench["Special-function benchmark<br/>[sf_performance.hpp]"]
  node_voronoibench["Voronoi benchmark"]
end

node_user(("C++ caller"))

node_user -->|"configures and uses"| node_number
node_number -->|"accepts backend concepts"| node_concepts
node_number -->|"selects backend"| node_cppint
node_number -->|"selects backend"| node_decimal
node_number -->|"selects backend"| node_binary
node_number -->|"selects backend"| node_complex
node_number -->|"selects backend"| node_rational
node_number -->|"selects backend"| node_gmp
node_number -->|"selects backend"| node_mpfr
node_number -->|"selects backend"| node_mpc
node_number -->|"selects backend"| node_tommath
node_number -->|"supports expression templates"| node_etops
node_number -->|"provides mathematical operations"| node_defaultops
node_number -->|"supports transcendental functions"| node_special
node_number -.->|"supports random operations"| node_random
node_number -.->|"supports primality testing"| node_miller
node_binary -->|"formats values"| node_format
node_sfbench -->|"includes backend"| node_arithbench
node_dfbench -->|"includes support"| node_dfbenchh
node_millerbench -->|"tests primality function"| node_miller
node_millerbench -->|"benchmarks backend"| node_gmp
node_millerbench -->|"benchmarks backend"| node_tommath
node_millerbench -->|"benchmarks backend"| node_cppint
node_voronoibench -->|"includes backend"| node_arithbench

click node_number "https://github.com/boostorg/multiprecision/blob/develop/include/boost/multiprecision/number.hpp"
click node_concepts "https://github.com/boostorg/multiprecision/blob/develop/include/boost/multiprecision/concepts/mp_number_archetypes.hpp"
click node_etops "https://github.com/boostorg/multiprecision/blob/develop/include/boost/multiprecision/detail/et_ops.hpp"
click node_defaultops "https://github.com/boostorg/multiprecision/blob/develop/include/boost/multiprecision/detail/default_ops.hpp"
click node_cppint "https://github.com/boostorg/multiprecision/blob/develop/include/boost/multiprecision/cpp_int.hpp"
click node_decimal "https://github.com/boostorg/multiprecision/blob/develop/include/boost/multiprecision/cpp_dec_float.hpp"
click node_binary "https://github.com/boostorg/multiprecision/blob/develop/include/boost/multiprecision/cpp_bin_float.hpp"
click node_complex "https://github.com/boostorg/multiprecision/blob/develop/include/boost/multiprecision/cpp_complex.hpp"
click node_rational "https://github.com/boostorg/multiprecision/blob/develop/include/boost/multiprecision/rational_adaptor.hpp"
click node_gmp "https://github.com/boostorg/multiprecision/blob/develop/include/boost/multiprecision/gmp.hpp"
click node_mpfr "https://github.com/boostorg/multiprecision/blob/develop/include/boost/multiprecision/mpfr.hpp"
click node_mpc "https://github.com/boostorg/multiprecision/blob/develop/include/boost/multiprecision/mpc.hpp"
click node_tommath "https://github.com/boostorg/multiprecision/blob/develop/include/boost/multiprecision/tommath.hpp"
click node_special "https://github.com/boostorg/multiprecision/blob/develop/include/boost/multiprecision/detail/functions/trig.hpp"
click node_random "https://github.com/boostorg/multiprecision/blob/develop/include/boost/multiprecision/random.hpp"
click node_miller "https://github.com/boostorg/multiprecision/blob/develop/include/boost/multiprecision/miller_rabin.hpp"
click node_format "https://github.com/boostorg/multiprecision/blob/develop/include/boost/multiprecision/cpp_bin_float/io.hpp"
click node_arithbench "https://github.com/boostorg/multiprecision/blob/develop/performance/arithmetic_backend.hpp"
click node_millerbench "https://github.com/boostorg/multiprecision/blob/develop/performance/miller_rabin_performance.hpp"
click node_dfbench "https://github.com/boostorg/multiprecision/blob/develop/performance/performance_test_df.cpp"
click node_dfbenchh "https://github.com/boostorg/multiprecision/blob/develop/performance/performance_test_df.hpp"
click node_sfbench "https://github.com/boostorg/multiprecision/blob/develop/performance/sf_performance.hpp"
click node_voronoibench "https://github.com/boostorg/multiprecision/blob/develop/performance/voronoi_performance.cpp"

classDef toneNeutral fill:#f8fafc,stroke:#334155,stroke-width:1.5px,color:#0f172a
classDef toneBlue fill:#dbeafe,stroke:#2563eb,stroke-width:1.5px,color:#172554
classDef toneAmber fill:#fef3c7,stroke:#d97706,stroke-width:1.5px,color:#78350f
classDef toneMint fill:#dcfce7,stroke:#16a34a,stroke-width:1.5px,color:#14532d
classDef toneRose fill:#ffe4e6,stroke:#e11d48,stroke-width:1.5px,color:#881337
classDef toneIndigo fill:#e0e7ff,stroke:#4f46e5,stroke-width:1.5px,color:#312e81
classDef toneTeal fill:#ccfbf1,stroke:#0f766e,stroke-width:1.5px,color:#134e4a
class node_number,node_concepts,node_etops,node_defaultops toneBlue
class node_cppint,node_decimal,node_binary,node_complex,node_rational toneAmber
class node_gmp,node_mpfr,node_mpc,node_tommath toneMint
class node_special,node_random,node_miller,node_format toneRose
class node_arithbench,node_millerbench,node_dfbench,node_dfbenchh,node_sfbench,node_voronoibench,node_user toneIndigo
```

## Components

### Generic Number API

- [Number interface](https://github.com/boostorg/multiprecision/blob/develop/include/boost/multiprecision/number.hpp): `include/boost/multiprecision/number.hpp`
- [Backend concepts](https://github.com/boostorg/multiprecision/blob/develop/include/boost/multiprecision/concepts/mp_number_archetypes.hpp): `include/boost/multiprecision/concepts/mp_number_archetypes.hpp`
- [Expression operations](https://github.com/boostorg/multiprecision/blob/develop/include/boost/multiprecision/detail/et_ops.hpp): `include/boost/multiprecision/detail/et_ops.hpp`
- [Default operations](https://github.com/boostorg/multiprecision/blob/develop/include/boost/multiprecision/detail/default_ops.hpp): `include/boost/multiprecision/detail/default_ops.hpp`

### Built-in Backends

- [Arbitrary integers](https://github.com/boostorg/multiprecision/blob/develop/include/boost/multiprecision/cpp_int.hpp): `include/boost/multiprecision/cpp_int.hpp`
- [Decimal floats](https://github.com/boostorg/multiprecision/blob/develop/include/boost/multiprecision/cpp_dec_float.hpp): `include/boost/multiprecision/cpp_dec_float.hpp`
- [Binary floats](https://github.com/boostorg/multiprecision/blob/develop/include/boost/multiprecision/cpp_bin_float.hpp): `include/boost/multiprecision/cpp_bin_float.hpp`
- [Complex numbers](https://github.com/boostorg/multiprecision/blob/develop/include/boost/multiprecision/cpp_complex.hpp): `include/boost/multiprecision/cpp_complex.hpp`
- [Rational numbers](https://github.com/boostorg/multiprecision/blob/develop/include/boost/multiprecision/rational_adaptor.hpp): `include/boost/multiprecision/rational_adaptor.hpp`

### External Backends

- [GMP backend](https://github.com/boostorg/multiprecision/blob/develop/include/boost/multiprecision/gmp.hpp): `include/boost/multiprecision/gmp.hpp`
- [MPFR backend](https://github.com/boostorg/multiprecision/blob/develop/include/boost/multiprecision/mpfr.hpp): `include/boost/multiprecision/mpfr.hpp`
- [MPC backend](https://github.com/boostorg/multiprecision/blob/develop/include/boost/multiprecision/mpc.hpp): `include/boost/multiprecision/mpc.hpp`
- [TomMath backend](https://github.com/boostorg/multiprecision/blob/develop/include/boost/multiprecision/tommath.hpp): `include/boost/multiprecision/tommath.hpp`

### Math and Interop

- [Math functions](https://github.com/boostorg/multiprecision/blob/develop/include/boost/multiprecision/detail/functions/trig.hpp): `include/boost/multiprecision/detail/functions/trig.hpp`
- [Random support](https://github.com/boostorg/multiprecision/blob/develop/include/boost/multiprecision/random.hpp): `include/boost/multiprecision/random.hpp`
- [Primality testing](https://github.com/boostorg/multiprecision/blob/develop/include/boost/multiprecision/miller_rabin.hpp): `include/boost/multiprecision/miller_rabin.hpp`
- [Float formatting](https://github.com/boostorg/multiprecision/blob/develop/include/boost/multiprecision/cpp_bin_float/io.hpp): `include/boost/multiprecision/cpp_bin_float/io.hpp`

### Performance Benchmarks

- [Arithmetic backend benchmark](https://github.com/boostorg/multiprecision/blob/develop/performance/arithmetic_backend.hpp): `performance/arithmetic_backend.hpp`
- [Miller–Rabin benchmark](https://github.com/boostorg/multiprecision/blob/develop/performance/miller_rabin_performance.hpp): `performance/miller_rabin_performance.hpp`
- [Decimal-float benchmark](https://github.com/boostorg/multiprecision/blob/develop/performance/performance_test_df.cpp): `performance/performance_test_df.cpp`
- [Benchmark support](https://github.com/boostorg/multiprecision/blob/develop/performance/performance_test_df.hpp): `performance/performance_test_df.hpp`
- [Special-function benchmark](https://github.com/boostorg/multiprecision/blob/develop/performance/sf_performance.hpp): `performance/sf_performance.hpp`
- [Voronoi benchmark](https://github.com/boostorg/multiprecision/blob/develop/performance/voronoi_performance.cpp): `performance/voronoi_performance.cpp`

### Other components

- **C++ caller**

## Connections

- C++ caller → Number interface: configures and uses (evidence: `README.md`)
- Number interface → Backend concepts: accepts backend concepts (evidence: `README.md`)
- Number interface → Arbitrary integers: selects backend (evidence: `README.md`)
- Number interface → Decimal floats: selects backend (evidence: `README.md`)
- Number interface → Binary floats: selects backend (evidence: `README.md`)
- Number interface → Complex numbers: selects backend (evidence: `README.md`)
- Number interface → Rational numbers: selects backend (evidence: `README.md`)
- Number interface → GMP backend: selects backend (evidence: `README.md`)
- Number interface → MPFR backend: selects backend (evidence: `README.md`)
- Number interface → MPC backend: selects backend (evidence: `README.md`)
- Number interface → TomMath backend: selects backend (evidence: `README.md`)
- Number interface → Expression operations: supports expression templates (evidence: `README.md`)
- Number interface → Default operations: provides mathematical operations (evidence: `README.md`)
- Number interface → Math functions: supports transcendental functions (evidence: `README.md`)
- Number interface → Random support: supports random operations
- Number interface → Primality testing: supports primality testing
- Binary floats → Float formatting: formats values (evidence: `include/boost/multiprecision/cpp_bin_float/io.hpp`)
- Special-function benchmark → Arithmetic backend benchmark: includes backend (evidence: `performance/sf_performance.hpp`)
- Decimal-float benchmark → Benchmark support: includes support (evidence: `performance/performance_test_df.cpp`)
- Miller–Rabin benchmark → Primality testing: tests primality function (evidence: `performance/miller_rabin_performance.hpp`)
- Miller–Rabin benchmark → GMP backend: benchmarks backend (evidence: `performance/miller_rabin_performance.hpp`)
- Miller–Rabin benchmark → TomMath backend: benchmarks backend (evidence: `performance/miller_rabin_performance.hpp`)
- Miller–Rabin benchmark → Arbitrary integers: benchmarks backend (evidence: `performance/miller_rabin_performance.hpp`)
- Voronoi benchmark → Arithmetic backend benchmark: includes backend (evidence: `performance/voronoi_performance.cpp`)
