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

Floating-point round-off problems.



    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

Have you considered using exact rational arithmetic instead of floating
point approximations? 

(- 6 59/10) 
==> 1/10

If you don't like reading these, you can have your output routines
convert them to floating point just for displaying to the user:

(coerce (- 6 59/10) 'float)
==> 0.1

Cheers,

CarlManning