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 all template<typename _Tp> variables marked [inline] and [constexpr], so _Tp is 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