Thanks John,
That seems to have worked for sqrt(pi). I'm also pretty new to c++ (I mostly code in fortran) which is probably where a lot of my confusions lie. I don't understand why I don't get the right answer with the declaration of pie I had before. In the real code I want to write I use sqrt of a float128 a lot and I want to be sure I am definitely not loosing precision as my overall calculation is extremely sensitive to precision. So how should I be declaring variables? I notice you had __float128. Does this do something different than just writing float128? I was already using using namespace boost::multi precision.
________________________________________
From: Boost-users
Hi Paul,
For a moment I thought that worked. It certainly does for log(2). I distinctly get two different values (with the first giving the "correct" value) if I try:
std::cout << std::setprecision(std::numeric_limits<float128>::max_digits10) << log(float128(2.q)) << std::endl;
std::cout << std::setprecision(std::numeric_limits<float128>::max_digits10) << log(2.q) << std::endl;
However, this isn't true for sqrt still. I checked by calculating the sqrt(pi) and comparing to
https://github.com/ned14/boost-trunk/blob/master/libs/multiprecision/test/te...
std::cout << std::setprecision(std::numeric_limits<float128>::max_digits10) << sqrt(float128(pie)) << std::endl;
std::cout << std::setprecision(std::numeric_limits<float128>::max_digits10) << sqrt(pie) << std::endl;
These two lines give me identical results and again only match the first 16 digits.
pie is defined as float128 and I copy/pasted the 100 digit value from the same test_sqrt.cpp given above.
I suspect an error in your declaration of pie, using this: using namespace boost::multiprecision; __float128 pie = boost::math::constants::pi<__float128>(); std::cout << std::setprecision(std::numeric_limits<float128>::max_digits10) << sqrt(float128(pie)) << std::endl; std::cout << std::setprecision(std::numeric_limits<float128>::max_digits10) << sqrt(pie) << std::endl; I see as output: 1.77245385090551602729816748334114514 1.77245385090551588191942755656782538 John. _______________________________________________ Boost-users mailing list Boost-users@lists.boost.org http://lists.boost.org/mailman/listinfo.cgi/boost-users