[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: Division in C++
From: |
Robert Heller |
Subject: |
Re: Division in C++ |
Date: |
Sun, 17 Jul 2005 22:32:37 +0200 |
Onno Garms <garms@gmx.de>,
In a message on 17 Jul 2005 13:53:37 -0400, wrote :
OG> On 12 Jul 2005 05:14:04 -0400, "Michael Tiomkin"
OG> <tmk@netvision.net.il> wrote:
OG>
OG>
OG> > There is an old rule: never assume or check equality of two floating
OG> >point numbers.
OG>
OG> I know about that rule, but I think it's a bad one.
It is a 'rule' based on the reality of *digital* 'floating point
numbers'. So long as you are using a floating point numbers on a
*digital* computer the rule applys.
OG>
OG> In our company's code, numerical problems are unavoidable and occur
OG> from time to time. Some colleagues introduce tolerances whereever
OG> doubles are compared. Eventually they have numerical problems in spite
OG> of the tolerance, modify the tollerance to fix it - and get another
OG> numerical problem some time later.
OG>
OG> My opinion is that it is better to introduce tolrances only in cases
OG> where it is absolutely unavoidable. The example discussed here is not
OG> among these.
OG>
OG> Keep rounding errors in the mind (e.g. do not write if (a<=b*c) break;
OG> but do not introduce numerical problems by using tolerances in cases
OG> where there are no initial numerical problems.
OG>
OG> The solution with long double works fine. The original code has been
OG> working fine for years on other operating systems.
OG>
OG> Thank you to everybody who posted a reply.
OG>
OG> Greetings,
OG> Onno
OG> [I agree. I know there's a meme of "all floating results are
OG> wrong" but it's not true. -John]
OG>
\/
Robert Heller ||InterNet: heller@cs.umass.edu
http://vis-www.cs.umass.edu/~heller || heller@deepsoft.com
http://www.deepsoft.com /\FidoNet: 1:321/153
- Division in C++, Onno Garms, 2005/07/11
- Re: Division in C++, Robert Heller, 2005/07/11
- Re: Division in C++, Antoun Kanawati, 2005/07/12
- Re: Division in C++, Marcin 'Qrczak' Kowalczyk, 2005/07/12
- Re: Division in C++, Michael Tiomkin, 2005/07/12
- Re: Division in C++, Florian Weimer, 2005/07/12
- Re: Division in C++, Henry Spencer, 2005/07/12