# Numerics

> C++ Atlas: `cppatlas.com/w/c/numeric` | Source: https://en.cppreference.com/w/c/numeric | Domain: Numerics | Standards: C23

The C numerics library includes common mathematical functions and types, as well as support for random number generation.

## Official Specification Summary (cppreference)

The C numerics library includes common mathematical functions and types, as well as support for random number generation.

### Common mathematical functions

The header `<math.h>` provides standard C library mathematical functions such as `fabs`, `sqrt`, and `sin`.

### Floating-point environment

The header `<fenv.h>` defines flags and functions related to exceptional floating-point state, such as overflow and division by zero.

### Pseudo-random number generation

The header `<stdlib.h>` also includes C-style random number generation via `srand` and `rand`.

### Complex number arithmetic

The header `<complex.h>` provides types and functions to work with complex numbers.

### Type-generic math

The header `<tgmath.h>` provides some macros for a function which names XXX:

- real function:

  - `float` variant `XXXf`
  - `double` variant `XXX`
  - `long double` variant `XXXl`

- complex function:

  - `float` variant `cXXXf`
  - `double` variant `cXXX`
  - `long double` variant `cXXXl`

### Bit manipulation (since C23)

The header `<stdbit.h>` provides macros and functions to work with the byte ordering and byte and bit representation of C objects.

### Checked integer arithmetic (since C23)

Provides some type-generic macros for checked integer arithmetic:

Defined in header `<stdckdint.h>`

- `ckd_add` (C23): checked addition operation on two integers (type-generic function macro)
- `ckd_sub` (C23): checked subtraction operation on two integers (type-generic function macro)
- `ckd_mul` (C23): checked multiplication operation on two integers (type-generic function macro)

### See also

- [C++ documentation for Numerics library](https://en.cppreference.com/w/cpp/numeric)

---
Attribution: content from https://en.cppreference.com/w/c/numeric (cppreference.com), licensed under CC-BY-SA 3.0 and GFDL. Modified: converted to markdown, study notes added. Offline snapshot of 9 February 2025.