std::numbers(3cxx)
β¨ NAME β¨
std::numbers β the namespace where all the iconic mathematical constants live π no cap. Also yes this is the manual page for std::numbers(3cxx), from the C++ standard library docs corner of the group chat.
πΈ SYNOPSIS πΈ
Variables
Variables
constexpr double e
template<typename _Tp> constexpr _Tp e_v
e
constexpr double egamma
template<typename _Tp> constexpr _Tp egamma_v
The Euler-Mascheroni constant.
constexpr double inv_pi
template<typename _Tp> constexpr _Tp inv_pi_v
1/pi
constexpr double inv_sqrt3
template<typename _Tp> constexpr _Tp inv_sqrt3_v
1/sqrt(3)
constexpr double inv_sqrtpi
template<typename _Tp> constexpr _Tp inv_sqrtpi_v
1/sqrt(pi)
constexpr double ln10
template<typename _Tp> constexpr _Tp ln10_v
log_e 10
constexpr double ln2
template<typename _Tp> constexpr _Tp ln2_v
log_e 2
constexpr double log10e
template<typename _Tp> constexpr _Tp log10e_v
log_10 e
constexpr double log2e
template<typename _Tp> constexpr _Tp log2e_v
log_2 e
constexpr double phi
template<typename _Tp> constexpr _Tp phi_v
The golden ratio, (1+sqrt(5))/2.
constexpr double pi
template<typename _Tp> constexpr _Tp pi_v
pi
constexpr double sqrt2
template<typename _Tp> constexpr _Tp sqrt2_v
sqrt(2)
constexpr double sqrt3
template<typename _Tp> constexpr _Tp sqrt3_v
sqrt(3)
so basically every constant comes in two flavours, bestie: a plain constexpr double with a short name, and a templated <name>_v version where _Tp is whatever type you feel like π. Pick ur fighter.
π¦ Detailed Description π¦
std::numbers is the namespace for mathematical constants. That's the whole vibe. It's giving "one job, done immaculately" π
. Detailed description said: namespace for mathematical constants. And honestly? That's it. That's the post. Periodt.
π Variable Documentation π
Every single one of these is [inline] and [constexpr], so they're compile-time cuties fr fr. Here's the full lineup, no skips:
template<typename _Tp> _Tp std::numbers::e_v [inline], [constexpr]βe. Euler's number, the main character of exponential growth π.template<typename _Tp> _Tp std::numbers::egamma_v [inline], [constexpr]β the Euler-Mascheroni constant. She's mysterious, she's iconic, she never got a closed form π.template<typename _Tp> _Tp std::numbers::inv_pi_v [inline], [constexpr]β1/pi. Pi, but flipped. Inverted queen π«Ά.template<typename _Tp> _Tp std::numbers::inv_sqrt3_v [inline], [constexpr]β1/sqrt(3). Yeah. That ratio.template<typename _Tp> _Tp std::numbers::inv_sqrtpi_v [inline], [constexpr]β1/sqrt(pi). Bestie she's the normal-distribution constant, lowkey famous π.template<typename _Tp> _Tp std::numbers::ln10_v [inline], [constexpr]βlog_e 10. Natural log of ten, slaying as always.template<typename _Tp> _Tp std::numbers::ln2_v [inline], [constexpr]βlog_e 2. Her little sister, equally booked and busy.template<typename _Tp> _Tp std::numbers::log10e_v [inline], [constexpr]βlog_10 e. Base-ten, base-queen β¨.template<typename _Tp> _Tp std::numbers::log2e_v [inline], [constexpr]βlog_2 e. Binary baddie π¦.template<typename _Tp> _Tp std::numbers::phi_v [inline], [constexpr]β the golden ratio,(1+sqrt(5))/2. Aesthetically perfect, obviously. Ate and left no crumbs π .template<typename _Tp> _Tp std::numbers::pi_v [inline], [constexpr]βpi. The blueprint. The blueprint of blueprints. The moment π₯§.template<typename _Tp> _Tp std::numbers::sqrt2_v [inline], [constexpr]βsqrt(2). First irrational number to ever be discovered and she has been booked ever since π.template<typename _Tp> _Tp std::numbers::sqrt3_v [inline], [constexpr]βsqrt(3). Hexagon girlie, geometry icon πΈ.
Reminder bestie: they're alltemplate<typename _Tp>variables marked[inline]and[constexpr], so_Tpis a type parameter and you get to pick the float type you want. Copy the names exactly, don't be out here inventing new ones π.
π Author π
Generated automatically by Doxygen for libstdc++ from the source code. Like, nobody hand-wrote this, it's a Doxygen robot and it deserves its flowers too π.
π«Ά Sign-off π«Ά
And that's the whole page, bestie!! This whole thing came to you courtesy of libstdc++, and yes the man page is literally called std::numbers(3cxx) β section 3cxx and all. mwah πβ¨
π¦ where this page comes from
- ubuntu resolute: libstdc++-12-doc 12.5.0-9ubuntu1
- ubuntu resolute: libstdc++-13-doc 13.4.0-10ubuntu1
- ubuntu stonking: libstdc++-12-doc 12.5.0-9ubuntu1
- ubuntu stonking: libstdc++-13-doc 13.5.0-1ubuntu1
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms