[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Spock@SAMSON.CADR.DIALNET.SYMBOLICS.COM: Floating-point round-off problems.]



    Date: Thu, 10 Aug 89 13:40:52 CDT
    From: mac%cadillac.cad.mcc.com@mcc.com (Mac Michaels)

    +>  Date: Thu, 10 Aug 89 08:00 PDT
    +>  From: Spock@SAMSON.CADR.DIALNET.SYMBOLICS.COM (Mr. Spock)
    +>  
    +>  Does anyone have a hack to correct for the losing floating-point math on
    +>  these Symbolics machines?
    +>  
    +>  Consider:
    +>  
    +>      (- 6 5.9) returns -> 0.099999905 instead of 0.1
    +>  
    +>  Thanks,
    +>  --Mark Alexander

    It looks like a problem common to more than Symbolics.  

It's a general problem with conversion between decimal and binary
floating point.  1/10 can't be represented exactly in binary floating
point -- it's a repeating fraction (just like 1/3 is in decimal).  The
closest approximation to 5.9 in binary floating point turns out to be
5.900000095367431640625 (see the documentation of the variable
*PRINT-EXACT-FLOAT-VALUE* to find out how to see the full value).

    Austin Kyoto Common Lisp on a Sun 4-110 returns:

    0.09999999999999964

This is what Symbolics returns if you use double-floats.  AKCL
presumably only has only one float format, double-float (understandable,
considering its C background, since pre-ANSI C favors use of doubles).

                                                barmar