Files
cppdraft_translate/cppdraft/numbers.md
2025-10-25 03:02:53 +03:00

41 lines
6.6 KiB
Markdown
Raw Blame History

This file contains invisible Unicode characters

This file contains invisible Unicode characters that are indistinguishable to humans but may be processed differently by a computer. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

[numbers]
# 29 Numerics library [[numerics]](./#numerics)
## 29.8 Numbers [numbers]
### [29.8.1](#syn) Header <numbers> synopsis [[numbers.syn]](numbers.syn)
[🔗](#header:%3cnumbers%3e)
namespace std::numbers {template<class T> constexpr T [e_v](#lib:e_v "29.8.1Header <numbers> synopsis[numbers.syn]") = *unspecified*; template<class T> constexpr T [log2e_v](#lib:log2e_v "29.8.1Header <numbers> synopsis[numbers.syn]") = *unspecified*; template<class T> constexpr T [log10e_v](#lib:log10e_v "29.8.1Header <numbers> synopsis[numbers.syn]") = *unspecified*; template<class T> constexpr T [pi_v](#lib:pi_v "29.8.1Header <numbers> synopsis[numbers.syn]") = *unspecified*; template<class T> constexpr T [inv_pi_v](#lib:inv_pi_v "29.8.1Header <numbers> synopsis[numbers.syn]") = *unspecified*; template<class T> constexpr T [inv_sqrtpi_v](#lib:inv_sqrtpi_v "29.8.1Header <numbers> synopsis[numbers.syn]") = *unspecified*; template<class T> constexpr T [ln2_v](#lib:ln2_v "29.8.1Header <numbers> synopsis[numbers.syn]") = *unspecified*; template<class T> constexpr T [ln10_v](#lib:ln10_v "29.8.1Header <numbers> synopsis[numbers.syn]") = *unspecified*; template<class T> constexpr T [sqrt2_v](#lib:sqrt2_v "29.8.1Header <numbers> synopsis[numbers.syn]") = *unspecified*; template<class T> constexpr T [sqrt3_v](#lib:sqrt3_v "29.8.1Header <numbers> synopsis[numbers.syn]") = *unspecified*; template<class T> constexpr T [inv_sqrt3_v](#lib:inv_sqrt3_v "29.8.1Header <numbers> synopsis[numbers.syn]") = *unspecified*; template<class T> constexpr T [egamma_v](#lib:egamma_v "29.8.1Header <numbers> synopsis[numbers.syn]") = *unspecified*; template<class T> constexpr T [phi_v](#lib:phi_v "29.8.1Header <numbers> synopsis[numbers.syn]") = *unspecified*; template<[floating_point](concepts.arithmetic#concept:floating_point "18.4.7Arithmetic concepts[concepts.arithmetic]") T> constexpr T e_v<T> = *see below*; template<[floating_point](concepts.arithmetic#concept:floating_point "18.4.7Arithmetic concepts[concepts.arithmetic]") T> constexpr T log2e_v<T> = *see below*; template<[floating_point](concepts.arithmetic#concept:floating_point "18.4.7Arithmetic concepts[concepts.arithmetic]") T> constexpr T log10e_v<T> = *see below*; template<[floating_point](concepts.arithmetic#concept:floating_point "18.4.7Arithmetic concepts[concepts.arithmetic]") T> constexpr T pi_v<T> = *see below*; template<[floating_point](concepts.arithmetic#concept:floating_point "18.4.7Arithmetic concepts[concepts.arithmetic]") T> constexpr T inv_pi_v<T> = *see below*; template<[floating_point](concepts.arithmetic#concept:floating_point "18.4.7Arithmetic concepts[concepts.arithmetic]") T> constexpr T inv_sqrtpi_v<T> = *see below*; template<[floating_point](concepts.arithmetic#concept:floating_point "18.4.7Arithmetic concepts[concepts.arithmetic]") T> constexpr T ln2_v<T> = *see below*; template<[floating_point](concepts.arithmetic#concept:floating_point "18.4.7Arithmetic concepts[concepts.arithmetic]") T> constexpr T ln10_v<T> = *see below*; template<[floating_point](concepts.arithmetic#concept:floating_point "18.4.7Arithmetic concepts[concepts.arithmetic]") T> constexpr T sqrt2_v<T> = *see below*; template<[floating_point](concepts.arithmetic#concept:floating_point "18.4.7Arithmetic concepts[concepts.arithmetic]") T> constexpr T sqrt3_v<T> = *see below*; template<[floating_point](concepts.arithmetic#concept:floating_point "18.4.7Arithmetic concepts[concepts.arithmetic]") T> constexpr T inv_sqrt3_v<T> = *see below*; template<[floating_point](concepts.arithmetic#concept:floating_point "18.4.7Arithmetic concepts[concepts.arithmetic]") T> constexpr T egamma_v<T> = *see below*; template<[floating_point](concepts.arithmetic#concept:floating_point "18.4.7Arithmetic concepts[concepts.arithmetic]") T> constexpr T phi_v<T> = *see below*; inline constexpr double [e](#lib:e "29.8.1Header <numbers> synopsis[numbers.syn]") = e_v<double>; inline constexpr double [log2e](#lib:log2e "29.8.1Header <numbers> synopsis[numbers.syn]") = log2e_v<double>; inline constexpr double [log10e](#lib:log10e "29.8.1Header <numbers> synopsis[numbers.syn]") = log10e_v<double>; inline constexpr double [pi](#lib:pi "29.8.1Header <numbers> synopsis[numbers.syn]") = pi_v<double>; inline constexpr double [inv_pi](#lib:inv_pi "29.8.1Header <numbers> synopsis[numbers.syn]") = inv_pi_v<double>; inline constexpr double [inv_sqrtpi](#lib:inv_sqrtpi "29.8.1Header <numbers> synopsis[numbers.syn]") = inv_sqrtpi_v<double>; inline constexpr double [ln2](#lib:ln2 "29.8.1Header <numbers> synopsis[numbers.syn]") = ln2_v<double>; inline constexpr double [ln10](#lib:ln10 "29.8.1Header <numbers> synopsis[numbers.syn]") = ln10_v<double>; inline constexpr double [sqrt2](#lib:sqrt2 "29.8.1Header <numbers> synopsis[numbers.syn]") = sqrt2_v<double>; inline constexpr double [sqrt3](#lib:sqrt3 "29.8.1Header <numbers> synopsis[numbers.syn]") = sqrt3_v<double>; inline constexpr double [inv_sqrt3](#lib:inv_sqrt3 "29.8.1Header <numbers> synopsis[numbers.syn]") = inv_sqrt3_v<double>; inline constexpr double [egamma](#lib:egamma "29.8.1Header <numbers> synopsis[numbers.syn]") = egamma_v<double>; inline constexpr double [phi](#lib:phi "29.8.1Header <numbers> synopsis[numbers.syn]") = phi_v<double>;}
### [29.8.2](#math.constants) Mathematical constants [[math.constants]](math.constants)
[1](#math.constants-1)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/numerics.tex#L10887)
The library-defined partial specializations
of mathematical constant variable templates
are initialized with the nearest representable values ofe,log2e,log10e,π,1π,1√π,ln2,ln10,√2,√3,1√3,
the Euler-Mascheroni γ constant, and
the golden ratio φ constant 1+√52,
respectively[.](#math.constants-1.sentence-1)
[2](#math.constants-2)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/numerics.tex#L10906)
Pursuant to [[namespace.std]](namespace.std "16.4.5.2.1Namespace std"),
a program may partially or explicitly specialize
a mathematical constant variable template
provided that the specialization depends on a program-defined type[.](#math.constants-2.sentence-1)
[3](#math.constants-3)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/numerics.tex#L10912)
A program that instantiates a primary template
of a mathematical constant variable template is ill-formed[.](#math.constants-3.sentence-1)