Subject: Re: [boost] [serialization] How are floating point values handled?
From: John Maddock (john_at_[hidden])
Date: 2013-08-08 07:01:16
>> Hmmm - that surprises me. I look at the code in the file
>> basic_text_oprimitive.hpp and I find:
>> void save(const float t)
>> // must be a user mistake - can't serialize un-initialized data
>> os << std::setprecision(std::numeric_limits<float>::digits10 + 2);
>> os << t;
>> Is this code not correct? Note that I added in 2 extra digits. Or
>> is this code not getting invoked? Let me know.
Ah, I think there are still 2 bugs:
* There's no special handling for long double - so it gets the default 5
* You don't output in scientific format: what that means in practice is that
if you write a number with a small exponent and it gets printed in fixed
format, then you get std::numeric_limits<float>::digits10 + 2 digits *after
the decimal point*. That may be too many digits if the exponent is > 0, but
if the exponent is < 0 then you get fewer *significant* digits printed than
you might expect, as the number will be 0.001234.... etc
And of course there's still no way to set the number of digits on UDT's
declared as primitives.
PS would it be OK to apply the patch from
Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk