|
Boost : |
Subject: [boost] [serialization] How are floating point values handled?
From: John Maddock (john_at_[hidden])
Date: 2013-08-07 13:21:28
I can't find anything in the docs about how floating point types are handled
by the serialization lib. It seems like text archives print however many
digits are specified in the ostream's precision is that correct? If so I
think this needs to be raised as a big red flag, because it means that
floating point values, uniquely compared to other primitives, do not round
trip by default. Except actually they do when using a binary archive.
This actually raises a problem when using text archives with floating point
data - if you want to be able to round trip the values, then how many digits
precision should you set the stream to? Particularly if you're saving a
complex structure containing different floating point types of differing
precisions?
I would have thought it would be better for the serialization lib to set the
stream precision before outputting a primitive type - to
std::numeric_limits<T>::max_digits10 (or std::numeric_limits<T>::digits10+2
if max_digits10 is not available). However, I recognize that this is a
difficult issue!
Cheers, John.
Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk