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

# Re: Floating point is like that... (was Re: Floating point error)

- Date: Wed, 13 Mar 1996 14:55:38 PST
- From:
- CC: moo-cows@parc.xerox.com
- In-reply-to: <9603132208.AA06055@tom.eng.mvision.com>

    >>>>> "Tom" == Tom Ritchford <tom@mvision.com> writes:

        Tom>     If programmers are assuming that they are going to get
        Tom> "exact" numbers with their floating point calculations, I
        Tom> fear that they will be sadly disappointed.  It's a really Bad
        Tom> Idea to test floating point numbers for equality -- you
        Tom> should always build in a little shrinkage into the tests, or
        Tom> else you will get a nasty surprise one day.  (ie, write abs(
        Tom> a-b ) < epsilon, rather than a == b, where epsilon is a small
        Tom> number.  If a and b can vary greatly in magnitude, try abs(
        Tom> a-b )/b < epsilon ((when b isn't zero of course!)))

        Tom>     Donald Knuth discusses this at great length in the Art of
        Tom> Computer Programming, vol 1.

        Tom>     /t

        Tom> Tom Ritchford tom@mvision.com, tom@weirdos.com

        Tom> Verge's "Little Idiot" -- Music for the mentally peculiar.
        Tom> 1-800-WEIRDOS http://www.fly.net/~tom/verge.html

    CORRECTION: Knuth vol 1 is "Fundamental Algorithms"; vol 2 is the
                desired reference -- "Seminumerical Algorithms".

    --
    -----------  "...  And the men went up and viewed Ai."  [Jos 7:2]  -----------
    Robert Jay Brown III  rj@eli.wariat.org  http://eli.wariat.org  1 847 705-0370
    Elijah Laboratories Inc;  759 Independence Drive;  Suite 5;  Palatine IL 60074
    -----  M o d e l i n g   t h e   M e t h o d s   o f   t h e   M i n d  ------

References:

- Floating point is like that... (was Re: Floating point error)

- From: tom@mvision.com (Tom Ritchford)

- Prev: Re: Floating point is like that... (was Re: Floating point error)
- Next: Re: Floating point is like that... (was Re: Floating point error)
- Index: MOO-cows
- Thread: MOO-cows

Home | Subject Index | Thread Index