Boost logo

Boost Users :

Subject: Re: [Boost-users] boost/multiprecision/float128
From: John Maddock (jz.maddock_at_[hidden])
Date: 2016-04-30 14:25:27


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/boost-trunk/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.


Boost-users 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