On Sun, 22 Jun 2008, Daniel Bünzli wrote: > Richard gave you the reason. > > If you can serialize to binary, you can acheive what you want by serializing > the 64 bits integers you get with Int64.bits_of_float and applying > Int64.float_of_bits to the integers you deserialize. Actually, for serialization, I strongly reccommend first using classify_float to split off and handle NaNs, Infinities, etc., then using frexp to split the float into a fraction and exponent. The exponent is just an int, and the fractional part can be multiplied by, say, 2^56 and then converted into an integer. The advantage of doing things this way, despite it being slightly more complicated, is two fold: one, it gaurentees you the ability to recovery the exact binary value of the float, and two, it sidesteps a huge number of compatibility issues between architectures- IIRC, IEEE 754 specifies how many bits have to be used to represent each part of the float, but not where they have to be in the word. Also, if you use hexadecimal for saving the integers, this can actually be faster than converting to base-10, as conversion to base-10 isn't cheap. It's a couple of more branches, but a lot of divs and mods get turned into shifts and ands. Brian