Boost logo

Boost Users :

Subject: Re: [Boost-users] [multiprecision] static_cast<cpp_bin_float_100> gives strange values.
From: John Maddock (jz.maddock_at_[hidden])
Date: 2018-04-20 17:02:17


On 20/04/2018 16:44, Vögl, Christian via Boost-users wrote:
> Hi everyone.
> The following Situation:
>
> I tried to improve the accuracy of a numerical function by replacing
> all double variables with cpp_bin_float_100.
> The parameters of this function contain two 3-element double arrays,
> which I convert to cpp_bin_float_100 by the following function:
>
> static void equal(cpp_bin_float_100* a, double* b)
> {
>
>     for(int i=0; i<3;i++)
>     {
>         a[i]=static_cast<cpp_bin_float_100>(b[i]);
>     }
> }
>
> the third element seems to be converted correctly, the first and
> second are totally off. (e. g. 100 -> 1.5625)

Well that's strange, I suspect that something else is going on here, and
I would need a self-contained test case to investigate.

BTW, the static_cast is unnecessary in this situation, and creates a
not-needed cpp_bin_float_100 temporary (narrow-to-wider conversions are
always implicit in the library).

Best, John.

---
This email has been checked for viruses by AVG.
http://www.avg.com

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