Boost logo

Boost :

Subject: Re: [boost] [serialization] round-trip serialization of float
From: Robert Ramey (ramey_at_[hidden])
Date: 2013-01-10 15:07:13


Olaf van der Spek wrote:
> On Thu, Jan 10, 2013 at 5:28 PM, Robert Ramey <ramey_at_[hidden]> wrote:
>> So, If you feel you need to preserver the exact set of bits - don't
>> use floating
>> point - use something else.
>
> Is it really unreasonable to expect a round trip to result in the same
> value on the same platform with the same code/binary?

yes

but don't take my word for it - ask an author of a standard
floating point library.

btw - if it's the same code/binary you can use binary_archive
which saves/loads the bits - not really the value. In this circumstance
the issue never arises. Maybe that's what you really want.

even with a text base archive, you would have the option
of saving your data as binary object. This would load
bit for bit the same. But the archive wouldn't be portable
accross platforms - thus defeating the motivating purpose
for a text base archive in the first place.

can't have it both ways.

Robert Ramey


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