|
fixed_point128 1.0.1.0
128 bit integer, fixed point and floating point arithmetic for C++20
|
Header-only 128-bit fixed-point arithmetic library. More...
#include <cmath>#include <format>#include <functional>#include <limits>#include <istream>#include <ostream>#include "fp128_shared.h"#include "fp128_decimal.h"Go to the source code of this file.
Classes | |
| class | fp128::fixed_point128< I > |
| Google test class (friend). More... | |
| class | std::numeric_limits< fp128::fixed_point128< I > > |
| Numeric properties of fixed_point128<I>. More... | |
| struct | std::hash< fp128::fixed_point128< I > > |
| Hash support, so a fixed_point128 can be a key in an unordered container. More... | |
| struct | std::formatter< fp128::fixed_point128< I >, char > |
| std::format support for fixed_point128. More... | |
Namespaces | |
| namespace | fp128 |
| Everything the library provides. | |
| namespace | std |
| STL namespace. | |
Macros | |
| #define | FP128_FIXED_POINT128_T_H |
Functions | |
| bool | fp128::Divide256By128 (uint64_t *q, uint64_t *r, const uint64_t *u, const uint64_t *v) noexcept |
| Divides a 256 bit numerator by a 128 bit divisor: the one call of div_128bit() in this header. | |
| template<int32_t I> | |
| std::ostream & | fp128::operator<< (std::ostream &os, const fixed_point128< I > &value) |
| Writes a fixed_point128 to a stream, honouring its width, fill and adjustment. | |
| template<int32_t I> | |
| std::istream & | fp128::operator>> (std::istream &is, fixed_point128< I > &value) |
| Reads a fixed_point128 from a stream, the way the builtin arithmetic extractors do. | |
CRT-Style Math Functions (Forward Declarations) | |
Free functions providing standard math library equivalents for float128. | |
| template<int32_t I> | |
| fixed_point128< I > | fp128::fabs (const fixed_point128< I > &x) |
| template<int32_t I> | |
| fixed_point128< I > | fp128::floor (const fixed_point128< I > &x) |
| template<int32_t I> | |
| fixed_point128< I > | fp128::ceil (const fixed_point128< I > &x) |
| template<int32_t I> | |
| fixed_point128< I > | fp128::trunc (const fixed_point128< I > &x) |
| template<int32_t I> | |
| fixed_point128< I > | fp128::round (const fixed_point128< I > &x) |
| template<int32_t I> | |
| int32_t | fp128::ilogb (const fixed_point128< I > &x) |
| template<int32_t I> | |
| fixed_point128< I > | fp128::copysign (const fixed_point128< I > &x, const fixed_point128< I > &y) |
| template<int32_t I> | |
| fixed_point128< I > | fp128::fmod (const fixed_point128< I > &x, const fixed_point128< I > &y) |
| template<int32_t I> | |
| fixed_point128< I > | fp128::modf (const fixed_point128< I > &x, fixed_point128< I > *iptr) |
| template<int32_t I> | |
| fixed_point128< I > | fp128::fdim (const fixed_point128< I > &x, const fixed_point128< I > &y) |
| template<int32_t I> | |
| fixed_point128< I > | fp128::fmin (const fixed_point128< I > &x, const fixed_point128< I > &y) |
| template<int32_t I> | |
| fixed_point128< I > | fp128::fmax (const fixed_point128< I > &x, const fixed_point128< I > &y) |
| template<int32_t I> | |
| fixed_point128< I > | fp128::hypot (const fixed_point128< I > &x, const fixed_point128< I > &y) |
| template<int32_t I> | |
| fixed_point128< I > | fp128::sqrt (const fixed_point128< I > &x, uint32_t iterations=3) |
| template<int32_t I> | |
| fixed_point128< I > | fp128::sin (fixed_point128< I > x) |
| template<int32_t I> | |
| fixed_point128< I > | fp128::asin (fixed_point128< I > x) |
| template<int32_t I> | |
| fixed_point128< I > | fp128::cos (fixed_point128< I > x) |
| template<int32_t I> | |
| fixed_point128< I > | fp128::acos (fixed_point128< I > x) |
| template<int32_t I> | |
| fixed_point128< I > | fp128::tan (fixed_point128< I > x) |
| template<int32_t I> | |
| fixed_point128< I > | fp128::atan (fixed_point128< I > x) |
| template<int32_t I> | |
| fixed_point128< I > | fp128::atan2 (fixed_point128< I > y, fixed_point128< I > x) |
| template<int32_t I> | |
| fixed_point128< I > | fp128::sinh (const fixed_point128< I > &x) |
| template<int32_t I> | |
| fixed_point128< I > | fp128::asinh (const fixed_point128< I > &x) |
| template<int32_t I> | |
| fixed_point128< I > | fp128::cosh (const fixed_point128< I > &x) |
| template<int32_t I> | |
| fixed_point128< I > | fp128::acosh (const fixed_point128< I > &x) |
| template<int32_t I> | |
| fixed_point128< I > | fp128::tanh (const fixed_point128< I > &x) |
| template<int32_t I> | |
| fixed_point128< I > | fp128::atanh (const fixed_point128< I > &x) |
| template<int32_t I> | |
| fixed_point128< I > | fp128::exp (const fixed_point128< I > &x) |
| template<int32_t I> | |
| fixed_point128< I > | fp128::exp2 (const fixed_point128< I > &x) |
| template<int32_t I> | |
| fixed_point128< I > | fp128::expm1 (const fixed_point128< I > &x) |
| template<int32_t I> | |
| fixed_point128< I > | fp128::pow (const fixed_point128< I > &x, const fixed_point128< I > &y) |
| template<int32_t I> | |
| fixed_point128< I > | fp128::log (fixed_point128< I > x) |
| template<int32_t I> | |
| fixed_point128< I > | fp128::log2 (fixed_point128< I > x) |
| template<int32_t I> | |
| fixed_point128< I > | fp128::log10 (fixed_point128< I > x) |
| template<int32_t I> | |
| fixed_point128< I > | fp128::logb (fixed_point128< I > x) |
| template<int32_t I> | |
| fixed_point128< I > | fp128::log1p (fixed_point128< I > x) |
Non-CRT Utility Functions (Forward Declarations) | |
| template<int32_t I> | |
| uint64_t | fp128::lzcnt128 (const fixed_point128< I > &x) |
| template<int32_t I> | |
| fixed_point128< I > | fp128::reciprocal (const fixed_point128< I > &x) |
| template<int32_t I> | |
| void | fp128::fact_reciprocal (int x, fixed_point128< I > &res) |
Variables | |
| constexpr uint64_t | fp128::fp128_trig_series_table [][2] |
| 1 / (n(n+1)) for n = 1..40, with 125 fraction bits rounded to nearest, {high, low}. | |
Header-only 128-bit fixed-point arithmetic library.
Provides the fixed_point128<I> template class where I is the number of integer bits (range [1, 63]), with one bit used for the sign and the remaining 127-I for the fractional part. Supports full arithmetic (+, -, *, /, %, shifts), comparison operators, type conversions (int, float, double, string), and a comprehensive set of math functions (sqrt, sin, cos, tan, atan, atan2, sinh, cosh, tanh, exp, log, pow, etc.).
Platform-specific intrinsics are used for MSVC and GCC/Clang to maximize performance. All methods are inline. The library is 64-bit only.
| I | Number of integer bits in [1, 63]. The fraction uses 127-I bits and the sign takes one. |
Definition in file fixed_point128.h.
| #define FP128_FIXED_POINT128_T_H |
Definition at line 72 of file fixed_point128.h.