문제

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.

도움이 되었습니까?

해결책

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.

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top