Numerics library

Math, random generation, complex arithmetic, constants, bit utilities, floating-point environment, and data-parallel numerics.

The C++ numerics area combines several different problem spaces: scalar arithmetic helpers, bit-level integer tools, mathematical functions, random engines and distributions, complex numbers, compile-time ratios, floating-point control, and newer data-parallel facilities. This hub is the curated entry point when you know the task is numeric, but not yet which numeric model or header family you need.

This page is a navigation hub, not a flattened numeric index. It links out to the canonical math, random, complex, ratio, SIMD, and C-compatibility destinations instead of duplicating their full inventories.

# Start Here

Mathematical functions

Use this route for scalar math, transcendental functions, classification helpers, rounding, and the broader <cmath> surface.

Random numbers and distributions

Start here when you need engines, distributions, seeding, or random-device entry points rather than deterministic arithmetic helpers.

Complex numbers

Use std::complex and its function family when the numeric model itself is complex-valued, not just formatted text or scalar math.

Bit and integer helpers

Use the <bit> family and neighboring numeric helpers for bit width/counting, rotations, byte swapping, and exact integer-oriented utilities.

# Quick Map

If you needStart withWhy
Scalar math, rounding, classification, or transcendental functionsMathThis is the main route for <cmath>-style facilities such as sqrt, log, hypot, classification predicates, and rounding behavior.
Mathematical constants or named numeric valuesConstants, <numbers>Use this route when the need is a named constant like pi, e, or related compile-time numeric values rather than a runtime computation.
Random engines, distributions, or non-deterministic seedingRandomThe random library separates engine choice, distribution choice, and seeding strategy in a way that is distinct from general-purpose arithmetic.
Complex arithmetic or complex-valued functionscomplexUse the complex route when the value model itself is complex rather than when you just need more math functions on real numbers.
Integer gcd/lcm, midpoint, interpolation, or saturating arithmeticgcd, lcm, midpoint, lerp, add_satThese helpers solve focused numeric tasks without requiring the full math or algorithm hubs.
Bit-level integer operations such as rotations, popcount, or width calculations<bit>, popcount, bit_width, byteswapThese are modern integer utilities aimed at representation-aware code, hashing primitives, encodings, and low-level performance work.
Compile-time rational arithmetic or unit-style ratiosratiostd::ratio is the dedicated compile-time numeric model, distinct from runtime math and random facilities.
Floating-point exception flags or rounding-mode controlFloating-point environmentThis route is for status flags and control modes, not general exception handling or arbitrary precision numerics.
Vectorized or data-parallel numericsSIMD, valarray, <linalg>These facilities are the right entry points when the question is about parallel numeric structure rather than just a scalar algorithm.

# Numeric Families

Scalar math

Core real-valued math functions, classifications, rounding modes, and the standard C-compatible math surface.

Bit and integer utilities

Representation-aware integer operations such as popcount, rotations, width detection, bit casting, and byte swapping.

Random

Pseudo-random engines, distributions, adapters, and seeding components for sampling and simulation tasks.

Complex arithmetic

Complex values, transcendental functions on complex numbers, user-defined imaginary literals, and polar/cartesian conversions.

Compile-time numerics

Ratios and associated arithmetic/comparison templates for type-level unit scales and exact rational constants.

Data-parallel numerics

SIMD and array-style numerics for wide-lane or vectorized computations, with valarray as the older array-expression route.

# Focused Numeric Helpers

Helper familyUse it forPrimary destinations
Arithmetic helpersExact integer relationships, interpolation, and midpoint-style calculations.gcd, lcm, midpoint, lerp
Saturating arithmeticOverflow-bounded integer arithmetic where saturation is the intended semantic model.add_sat, sub_sat, mul_sat, div_sat, saturate_cast
Bit manipulationPopulation counts, shifts-as-rotations, bit widths, and representation transforms.popcount, countl_zero, countr_zero, byteswap, bit_cast
Floating-point environmentStatus flags, exceptions, and rounding mode control around floating-point evaluation.fenv, fetestexcept, feround

# Modern Additions

StandardWhat became easier to navigate
C++17gcd and lcm provide direct integer relationship helpers that used to require ad hoc implementations.
C++20<bit>, constants, midpoint, and lerp added a major modern wave of low-level and numerical convenience utilities.
C++23Constexpr expansion across math and newer fixed-width floating-point support make older numeric pages intersect more with modern compile-time and portability concerns.
C++26SIMD, <linalg>, and the saturating arithmetic family make the numerics hub much broader than the legacy math/random view.

# Adjacent Hubs And Boundaries

This hub coversUse a different hub for
Math, random generation, complex numbers, bit utilities, ratios, floating-point environment, and data-parallel numeric facilities.Algorithms for generic sequence-processing algorithms, Chrono for date/time modeling, Utility for formatting and char conversions, and Type support for traits and numeric limits.
Modern C++ numeric facilities.C numerics when you need the C-side compatibility surface or a C-only math/fenv/random route.