Onno Garms <[EMAIL PROTECTED]>,
  In a message on 17 Jul 2005 13:53:37 -0400, wrote :

OG> On 12 Jul 2005 05:14:04 -0400, "Michael Tiomkin"
OG> <[EMAIL PROTECTED]> 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:   [EMAIL PROTECTED]
http://vis-www.cs.umass.edu/~heller  ||            [EMAIL PROTECTED]
http://www.deepsoft.com              /\FidoNet:    1:321/153






                                                                  
_______________________________________________
Help-gplusplus mailing list
[email protected]
http://lists.gnu.org/mailman/listinfo/help-gplusplus

Reply via email to