[Cryptography] floating point

Henry Baker hbaker1 at pipeline.com
Wed Dec 24 20:55:34 EST 2014


At 09:08 AM 12/24/2014, Jerry Leichter wrote:
>Attempting to save and then read back FP numbers in decimal format is either straightforward - if your programming language provides a direct way to do it - or an "advanced topic" if it doesn't.  (Modula-3 may have been the first language to provide an explicit way to do this; its default method for printing an FP method produced (one of the set of) decimal representations for the FP value given that was (a) as short as possible; (b) if read by the corresponding default FP reader, would re-create the same bit pattern as the original value.  This isn't true of at least C or FORTRAN:  FORTRAN D or F or G format, and the C %f/%g formats they inspired, when given no precision, simply arbitrarily give you 6 digits.  If you want to do a round-trip, you have to figure out the appropriate representation for yourself.
>
>At about the same time, a pair of papers by different sets of authors, by coincidence, were submitted to and appeared in some ACM conference (I forget which), one on how to print FP numbers efficiently and correctly, one on how to read them.  Most implementations at the time were either inefficient, incorrect, or often both.

I'm sorry to disappoint you re Modula-3, but I believe that the Lisp/Scheme reader/printer was the first to satisfy the axiom:

EQUAL(x,READ-FROM-STRING(PRINT-TO-STRING(x))) is true

Actually, in the case of floating point numbers, they aren't just EQUAL, but bit-for-bit identical (variously called EQ or EQL, depending upon whether floating point numbers are "immediate" or not).

The authors of the papers included Guy Steele, Jon White and Will Clinger.

Proceedings  of the ACM SIGPLAN’SO  Conference  on
Programming  Language  Design and Implementation.
White  Plains, New York, June  20-22,  1990.

http://www.cesura17.net/~will/professional/research/papers/howtoread.pdf

https://lists.nongnu.org/archive/html/gcl-devel/2012-10/pdfkieTlklRzN.pdf




More information about the cryptography mailing list