[multiprecision] static_cast<cpp_bin_float_100> gives strange values.
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
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
(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
participants (2)
-
John Maddock
-
Vögl, Christian