www.delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp/1996/02/13/15:39:22

Xref: news2.mv.net comp.lang.c:56292 comp.lang.c++:72335 comp.os.msdos.djgpp:1088 gnu.g++.help:4606 gnu.gcc.help:5808
From: hogend AT artas DOT nlr DOT nl (hogendoorn r.a.)
Newsgroups: comp.lang.c,comp.lang.c++,gnu.gcc.help,gnu.g++.help,comp.os.msdos.djgpp
Subject: Re: float != float and floats as return types
Date: 13 Feb 1996 12:34:34 +0100
Organization: NLR
Lines: 34
Sender: hogend AT artas DOT nlr DOT nl
Message-ID: <yymg2cfzcfp.fsf@artas.nlr.nl>
References: <DM19oy DOT KsJ AT granite DOT mv DOT net> <4es0ep$is2 AT fu-berlin DOT de>
NNTP-Posting-Host: artas.nlr.nl
In-reply-to: axl@zedat.fu-berlin.de's message of Fri, 02 Feb 1996 03:31:08 GMT
To: djgpp AT delorie DOT com
DJ-Gateway: from newsgroup comp.os.msdos.djgpp

In article <4es0ep$is2 AT fu-berlin DOT de> axl AT zedat DOT fu-berlin DOT de (Axel Thimm) writes:

....
   The reason I "expored" this behaviour was an optimization by hand of a
   simulation program. A lattices site value is very often used in
   quadratic terms, so introducing a second lattice and storing theese
   values seemed like just speeding up the process. I was amazed when the
   output changed (the results were still within the stat. error).
   So if someone is writing programs that can do exactly the same thing
   with two different implementations, then he would very much like to turn
   such optimizations temporarily off, to get the same results. Later he
   would turn them on again.
....

My advice: get a good book on numerical math and read the section on
condition numbers. Any inexact computation (whether using floats,
doubles or quads) will lead to an inexact result, bounded by the
condition number of your computation times the machine precision
(which is, of course, different for floats, doubles and quads). Any
result within this threshold (which may be a pessimistic bound though)
is "correct". As an example, consider

 (1.1 * 1.1) - exp (2.0 * log (1.1))

which will not be zero, although both factors are (mathematically) equal.
The second computation, however, has a worse condition number.
-- 
                                                     /
R. A. Hogendoorn                                    /__
Informatics Division                               /   \
National Aerospace Laboratory The Netherlands     ( NLR )
E-mail: hogend AT nlr DOT nl                              \___/
Tel. +31-527-24-8376                                  /
Fax. +31-527-24-8210                                 /

- Raw text -


  webmaster     delorie software   privacy  
  Copyright © 2019   by DJ Delorie     Updated Jul 2019