Boost logo

Boost :

Subject: Re: [boost] [serialization]Double rounding bug?
From: John Maddock (john_at_[hidden])
Date: 2009-10-02 04:08:11


>> DoubleValue doubleValue1;
>> doubleValue1.m_value = -0.0070850229047457131;
>> SaveDoubleValue(doubleValue1, "DoubleValue.xml");
>>
>> DoubleValue doubleValue2;
>> LoadDoubleValue(doubleValue2, "DoubleValue.xml");
>> //but from file is read -0.007085022904745714
>> assert(doubleValue1.m_value==doubleValue2.m_value);
>
> That value would require between 50 and 60 bits of precision, provided its
> representation is actually possible in a binary floating point number.
> Typical
> double-precision floating point numbers have a fraction of 52 bits, so the
> changes you are reporting are actually to be expected.

I don't believe that's true: ideally the two values should have the same
binary representation. In this case the relative difference between the two
values is 1.6e-17 or about 1eps: so my guess is they differ in the last
significant bit - that's not a double rounding issue, or shouldn't be.
However, I suspect this to be an MSVC issue - there are some numbers that
MSVC's IOStreams library can't "round trip serialize" - Robert does
Boost.Serialization rely on iostreams internally in this case? I'm cc'ing
Paul Bristow on this one, because I know he investigated this issue a while
back.

HTH, John.


Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk