From: Fernando Cacciola (fcacciola_at_[hidden])
Date: 2002-02-27 18:32:00
----- Original Message -----
From: "rameysb" <ramey_at_[hidden]>
Sent: Wednesday, February 27, 2002 7:51 PM
Subject: [boost] Re: Serialization (Persistence) library draft submission
> > >
> > Does this mean that everything is serialized as text?
> > If I have a long double value, will it be serialized as a text
> > In this case, is it guaranteed that the de-serialized value will be
> > identical to the serialized one? (this requires a careful fp<-
> > conversion)
> > Fernando Cacciola
> > Sierra s.r.l.
> > fcacciola_at_g...
> > www.gosierra.com
> Yes it does - everying is serialized as text - see the rational for
> this with the documentation.
> floats and doubles are rendered in the maximum precision the the C++
> implementation permits.
Actually, there is not such a thing as a C++ implementation (unless you are
referring to a compiler, but that's not the case).
There are library implementations.
In this particular case, it's the std 'ostream' and 'istream'
implementations that matter.Which is typically vendor-specific.
The problem is that the std does not *require* that ostream and istream
behave in they way you expect (retrieving the exact same value provided
apropriate setprecision()), even if used within the same
In fact, the specification for numeric_limits<T>::digits10 doesn't express
precisely that this number should allow exact binary to decimal conversions.
It is true that most std library implementation do the right thing, but your
library is depending on it, which IMO is not a good thing.
BTW, in your code you've used numeric_limits<>::digits, instead of digits10.
'digits' is the number of 'binary' digits, not decimal.
Furthermore, in your code, for the 'long double' version, there isn't a
'setprecision' guard as in the other cases.
IMO, since the purpose of writing an fp value is to retrieve exactly later,
I'll recommend that you use your own fp-binary-to/from-decimal conversion
> If the archive read by an implementation
> that supports lower precision - data will be lost. This is not
> addressable from this library.
> In general there is no guarentee that floating/doulble values will be
> exactly ported from environment to environment. Indeed it is
> impossible to implement such a guarentee.
> On the same environment - no precision should be lost.
> Robert Ramey
> Info: http://www.boost.org Send unsubscribe requests to:
> Your use of Yahoo! Groups is subject to http://docs.yahoo.com/info/terms/
Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk