There is a rather silly problem with the number pi in C and C++. As far as I know M_PI
defined in math.h
is not required by any standard.
New C++ standards introduced a lot of complicated math in the standard library - hyperbolic functions, std::hermite
and std::cyl_bessel_i
, different random number generators and so on and so forth.
Did any of the 'new' standards bring in a constant for pi? If not - why? How does all this complicated math work without it?
I am aware of similar questions about pi in C++ (they are several years and standards old); I would like to know the current state of the problem.
I am also very interested in why oh why C++ still doesn't have a pi constant but has a lot of more complicated math.
I know that I can define pi myself as 4*atan(1)
or acos(-1)
or double pi = 3.14;
. Sure. But why do I still have to do it? How do standard math functions work without pi?
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…