OM Floats : conversion
Richard J. Fateman
fateman at cs.berkeley.edu
Fri Jul 9 20:41:21 CEST 1999
see http://www.cs.berkeley.edu/~wkahan/ieee754status/ieee754.ps
In fact, if we agree on the ordering of bytes in words (which computers
don't, of course), then the ordering of bits in IEEE format numbers
is specified. So other than big/little endian, maybe we can encode
floats as one or more 32-bit quantities. How do you want to send
32-bit quantities? Signed integers? hex strings? If we agree on
hex character strings, then a double takes exactly 16 characters.
Hex is fairly pointless for this purpose.
If we use all the 127 ASCII printing characters, we get 8 chars
(actually we need only 7 chars+ 1 bit.).
If you want to send doubles as decimal floats, here's a useful fact.
If you start with a decimal number input of 15 digits, then
correct IEEE decimal/binary/decimal conversion must give you
the same 15 digits output.
If you start with a binary number (double) and do binary/decimal/binary
conversion, to guarantee the same binary number, you may need 17 decimal
digits. That's just for the fraction. Not counting exponent, decimal
point, sign etc. Random floating-point numbers are probably going
to need 21 characters or more.
Cheers.
RJF
More information about the Om
mailing list