From: Fernando Cacciola (fcacciola_at_[hidden])
Date: 2002-03-01 15:53:41
----- Original Message -----
From: "Beman Dawes" <bdawes_at_[hidden]>
To: <boost_at_[hidden]>; <boost_at_[hidden]>
Sent: Friday, March 01, 2002 5:15 PM
Subject: Re: [boost] Re: Serialization (Persistence) library draft
> >The issue that has concerned me is what happens when an archive
> >is created on a machine with 80 bit IEEE floating point doubles and
> >this archive is read by a program using the same serialization
> >library on a machine which has 64 bit doubles. if the second program
> >reads 80 bits is it going to have to include code to convert from
> >every known binary double format to every other one? The same
> >issues occur on sizes of other binaries 16 vs 32 vs 64. The same
> >issue arises when considering that some machines store integers
> >in little endien order (intel) while others store them
> >in big endien order (sparc). I doubt anyone will want to
> >consider all these issues.
> Well, there are plenty of existence proofs of portable binary databases,
> including huge commercial successes.
> What about XDR for example?
> Or closer to home, I've got one b-tree file format that has been used for
> 18 years, on everything from in-vehicle embedded systems up to the largest
> mainframes. The same data files can be read by all.
> Here is how it is done: No floating point. Integer and unsigned in
> of 8, 16, 24, and 32 bits.
The no-floating point part is not really a problem.
Any floating point number can be expressed in terms of integers and
reconstructed back from that if the right additional information is stored.
(after all, the different parts of a fp number are internally integers).
So, it is possible to create a function to convert a given floating point
number into a struct of integers which can describe the number with no loss
of precision, and another function to recover the number back.
The struct must contain additional information fields, such as the number of
bits originally used for the mantissa and exponent, the exponent bias,
This can be used to support fp serialization with a low-level system as the
one described by Beman.
I don't have right now any code to do that 'floating point dissection
portably, but I point this out to state that a portable binary serialization
of integers is all that is really needed.
Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk