creating math constants of variable precision using Boost mpfr_float, such as pi or e

后端 未结 1 690
孤街浪徒
孤街浪徒 2021-01-26 00:59

I am using Boost.Multiprecision for wrappers around the mpfr backend, and I am having some trouble creating pi (and e or any other math constant) to my desired precision. I fee

相关标签:
1条回答
  • 2021-01-26 01:21

    The constants embedded in the Boost headers have a limited precision, and you've hit that limit. If you need a higher-precision version of pi (for instance), you'll need to bring it yourself.

    For instance, the definition of boost::math::constants::pi in the headers is:

      BOOST_DEFINE_MATH_CONSTANT(pi, 3.141592653589793238462643383279502884e+00, "3.14159265358979323846264338327950288419716939937510582097494459230781640628620899862803482534211706798214808651e+00")
    

    — https://github.com/boostorg/math/blob/master/include/boost/math/constants/constants.hpp

    (This definition only gives 110 digits past the decimal place, by the way. Any digits you're getting beyond that are likely to be incorrect!)

    0 讨论(0)
提交回复
热议问题