[clean-list] Serializing Atomic Data Types...

Richard A. O'Keefe ok@atlas.otago.ac.nz
Fri, 17 Nov 2000 10:21:27 +1300 (NZDT)


Fabien Todescato <f.todescato@larisys.fr> wrote:
	Is there an efficient means to convert Reals and Ints to their binary
	representation stored in a String, and back ?
	
You can always use the foreign interface.

The basic problem is that Reals and Ints don't *have* a platform-independent
binary representation.  I have three working computers in my office; two of
them agree about the representation of Reals and Ints, but the third,
a rather popular architecture, does not.

For serialisation, you should look at XDR and ANS.1; if you convert Reals
and Ints to the XDR representation (which may be the same as the native
binary representation on some machines, but won't be on others) then your
binary data can be exchanged between machines without having to worry.
But if you do that, the crude type punning C trick you mention will no longer
suffice.