Mathematical constants in C++20

CMP
1 min readDec 20, 2023

It is no secret that using constants in your C++ code can make your code easier to read and maintain, allowing you to eliminate magic numbers, aka raw numerical values floating in your code with no clear meaning or definition. A simple const or constexpr (see here to learn more about the differences) can quickly improve the quality of your code.

Some numbers are easily recognizable from their raw numerical values. Consider 3.14, the widely known constant for pi — a C++ program that calculates nearly any mathematical value involving curves will need to use the value of pi in…

--

--

CMP

Software engineer specializing in operating systems, navigating the intracicies of the C++ language and systems programming.