Starting from C++20, mathematical constants are defined in the header <numbers>
.
You should prefer using them instead of hardcoding your own constants.
Noncompliant code example
const double pi = 3.14159265358979323846; // Noncompliant
auto computeCirclePerimeter(double radius) {
return 2 * pi * radius;
}
Compliant solution
#include <numbers>
auto computeCirclePerimeter(double radius) {
return 2 * std::numbers::pi * radius;
}