libfxd 0.2.dev
A fixed-point library for C++.
Loading...
Searching...
No Matches
numbers.hpp
Go to the documentation of this file.
1/*
2 * libfxd - a fixed-point library for C++
3 *
4 * Copyright 2023 Daniel K. O.
5 * SPDX-License-Identifier: Apache-2.0
6 */
7
8#ifndef LIBFXD_NUMBERS_HPP
9#define LIBFXD_NUMBERS_HPP
10
11#include <numbers>
12
13#include "concepts.hpp"
14
15
17namespace std::numbers {
18
19#ifdef __cpp_lib_constexpr_cmath
20# define LIBFXD_CONSTEXPR constexpr
21#else
22# define LIBFXD_CONSTEXPR const
23#endif
24
25#define LIBFXD_NUMBER(c) \
26 template<fxd::fixed_point Fxd> \
27 inline LIBFXD_CONSTEXPR \
28 Fxd c<Fxd> = Fxd{std::numbers:: c <typename std::numeric_limits<Fxd>::float_type>}
29
32
34 LIBFXD_NUMBER(egamma_v);
35
37 LIBFXD_NUMBER(inv_pi_v);
38
40 LIBFXD_NUMBER(inv_sqrt3_v);
41
43 LIBFXD_NUMBER(inv_sqrtpi_v);
44
47
50
52 LIBFXD_NUMBER(log10e_v);
53
55 LIBFXD_NUMBER(log2e_v);
56
59
62
64 LIBFXD_NUMBER(sqrt2_v);
65
67 LIBFXD_NUMBER(sqrt3_v);
68
69
70#undef LIBFXD_NUMBER
71#undef LIBFXD_CONSTEXPR
72
73}
74
75#endif
Specialization for mathematical constants.
Definition: numbers.hpp:17
#define LIBFXD_NUMBER(c)
Definition: numbers.hpp:25