kennen:include:numbers
<numbers>
Mathematische Konstanten std::numbers::pi
aus Template-Werten std::numbers::pi_v<double>
:
e | Eulersche Zahl e = 2.71828… |
log2e | $\log_2 e$ |
log10e | $\log_{10} e$ |
pi | $\pi$ = 3.14159… |
inv_pi | $1/\pi$ |
inv_sqrtpi | $1/\sqrt\pi$ |
ln2 | $\ln 2$ |
ln10 | $\ln 10$ |
sqrt2 | $\sqrt 2$ |
sqrt3 | $\sqrt 3$ |
inv_sqrt3 | $1/\sqrt 3$ |
egamma | Euler-Mascheroni-Konstante $\gamma$ = 0.5772… |
phi | Goldener Schnitt $\phi = \frac{1+\sqrt{5}}{2}$ = 1.618… |
Beispiel
- numbers.cpp
#include <iostream> #include <numbers> int main() { std::cout << "e = " << std::numbers::e << '\n'; std::cout << "log2e = " << std::numbers::log2e << '\n'; std::cout << "log10e = " << std::numbers::log10e << '\n'; std::cout << "pi = " << std::numbers::pi << '\n'; std::cout << "inv_pi = " << std::numbers::inv_pi << '\n'; std::cout << "inv_sqrtpi = " << std::numbers::inv_sqrtpi << '\n'; std::cout << "ln2 = " << std::numbers::ln2 << '\n'; std::cout << "ln10 = " << std::numbers::ln10 << '\n'; std::cout << "sqrt2 = " << std::numbers::sqrt2 << '\n'; std::cout << "sqrt3 = " << std::numbers::sqrt3 << '\n'; std::cout << "inv_sqrt3 = " << std::numbers::inv_sqrt3 << '\n'; std::cout << "egamma = " << std::numbers::egamma << '\n'; std::cout << "phi = " << std::numbers::phi << '\n'; }
kennen/include/numbers.txt · Zuletzt geändert: 2020-06-01 13:15 von 127.0.0.1