
Boost Users : 
Subject: Re: [Boostusers] boost/multiprecision/float128
From: Cooper, Bridgette R D (b.cooper_at_[hidden])
Date: 20160430 15:10:42
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: Boostusers <boostusersbounces_at_[hidden]> on behalf of John Maddock <jz.maddock_at_[hidden]>
Sent: Saturday, April 30, 2016 7:25:27 PM
To: boostusers_at_[hidden]
Subject: Re: [Boostusers] boost/multiprecision/float128
On 30/04/2016 18:38, Cooper, Bridgette R D wrote:
>
> 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/boosttrunk/blob/master/libs/multiprecision/test/test_sqrt.cpp
>
>
> 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.
_______________________________________________
Boostusers mailing list
Boostusers_at_[hidden]
http://lists.boost.org/mailman/listinfo.cgi/boostusers
Boostusers list run by williamkempf at hotmail.com, kalb at libertysoft.com, bjorn.karlsson at readsoft.com, gregod at cs.rpi.edu, wekempf at cox.net