jakub_neruda, Czech Tip 15 of #TuesdayCodingTips - Mathematical constants in C++
Since C++20, you can include header <numbers> and use many commonly used, precomputed mathematical constants like Pi, Phi, square root of 2 and 3, natural logarithms of 2 and 10, and many more! Even better, you can choose their precision by specifying the underlying type via a template.
And since C++17, the <cmath> header contains some special math functions I've never heard of like cylindrical Bessel functions, associated Legendre polynomials, or Riemann zeta function.
Constants are here: https://en.cppreference.com/w/cpp/numeric/constants
Special functions are here: https://en.cppreference.com/w/cpp/numeric/special_functions
Add comment