Boost logo

Boost :

From: Paul A Bristow (pbristow_at_[hidden])
Date: 2006-03-16 09:19:05


 

| -----Original Message-----
| From: boost-bounces_at_[hidden]
| [mailto:boost-bounces_at_[hidden]] On Behalf Of John Maddock
| Sent: 16 March 2006 13:43
| To: boost_at_[hidden]
| Subject: Re:
| [boost][serialization]Serialisation/deserialisationoffloating-
| point values
|
| > Anything that guarantees a round trip MUST be a good.
| >
| > (Getting output and input right would be even better! There are
| > papers which present methods for doing it which claim to be proven
| > correct - but these are not the methods used for popular
| > implmentations.)
| >
| > Is a hex fully portable? It surely just promises to be as close as
| > the FP representation will allow? Or should we store the FP
| > representation in the serialization and only deserialize if it
| > matches exactly? This sounds a prudent move to me.
|
| Um, what do you mean by fully portable? It is in the sense that:
|
| * If you do a write-then-read cycle on the same machine you
| get back exactly
| the same result.
| * If you do a write-then-read cycle on different machines you
| only get the
| same result back if the machine reading the value has at
| least as many bits
| in it's mantissa as the machine used for writing. But that
| goes without
| saying really.
|
| I guess I really should put my money where my mouth is and
| present some
| sample code, I'll see what I can do later....
|
| John.

That would be excellent.

My suggestion is to store the FP format somehow and somewhere in the
serialization.

http://babbage.cs.qc.edu/courses/cs341/IEEE-754references.html#tables

lists half a dozen IEEE formats, so a single byte would suffice, but it
might be better to cater for User Defined Types by storing the number of
significand and exponent bit counts separately? Some 128-bit types like
doubledouble Darwin and 265-bit reals are in use, as well as arbitrary
precision like NTL ZZ.

Some users might also want to use 'exact reals', for example

http://keithbriggs.info/xrc.html (note that C and C++ implmentations exist)

so it might be useful to cater for this as well.

Paul

-- 
Paul A Bristow
Prizet Farmhouse, Kendal, Cumbria UK LA8 8AB
Phone and SMS text +44 1539 561830, Mobile and SMS text +44 7714 330204
mailto: pbristow_at_[hidden]  http://www.hetp.u-net.com/index.html
http://www.hetp.u-net.com/Paul%20A%20Bristow%20info.html

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