Nick
Nick

Reputation: 3435

Does the C++ Standard Library define pi?

Does STL contain definition for pi (=3.14...)? Certainly, I can use old good M_PI, but it is non-standard and not cross-compiler compliant.

Upvotes: 5

Views: 8788

Answers (1)

Marshall Clow
Marshall Clow

Reputation: 16670

Boost.Math defines pi (and many other) mathematical constants to very high precision

#include <boost/math/constants.hpp>
long double pi = boost::math::constants::pi<long double>();

A full list is available here.

Upvotes: 4

Related Questions