delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp/1999/09/29/12:39:57

From: broeker AT acp3bf DOT knirsch DOT de (Hans-Bernhard Broeker)
Newsgroups: comp.os.msdos.djgpp
Subject: Re: djgpp and rounding errors
Date: 29 Sep 1999 13:08:48 +0200
Organization: RWTH Aachen, III. physikalisches Institut B
Message-ID: <7sss00$rdo@acp3bf.knirsch.de>
References: <37F173EB DOT 77A2 AT linetap DOT com>
NNTP-Posting-Host: acp3bf.physik.rwth-aachen.de
X-Trace: nets3.rz.RWTH-Aachen.DE 938603333 8897 137.226.32.75 (29 Sep 1999 11:08:53 GMT)
X-Complaints-To: abuse AT rwth-aachen DOT de
NNTP-Posting-Date: 29 Sep 1999 11:08:53 GMT
X-Newsreader: TIN [version 1.2 PL2]
Lines: 31
To: djgpp AT delorie DOT com
DJ-Gateway: from newsgroup comp.os.msdos.djgpp
Reply-To: djgpp AT delorie DOT com

nebo (nebo AT linetap DOT com) wrote:
> Does DJGPP fix rounding errors with decimal places?  

No, because it's not the compiler's business at all to 'fix' rounding
errors. Rouding errors are a fact of life when you deal with floating
point calculation. There's neither a need, nor a chance to 'fix' them.
Your code has to be aware of them, at all times, to work properly.

To put it in a well-known aphorism:

	In computing, 10.0 * 0.1 is hardly ever 1.0

(And no 'magic' will remove this feature entirely, for you).

> I know some compilers use BCD math to circumvent this problem, but I
> found nothing of the sort in DJGPP.

BCD math is most definitely not used by any C compiler for the purpose
of 'circumventing' the problem, because it doesn't circumvent it, at
all. BCD math, or any use of decimal system for floating point
numbers, just moves the rounding errors into regions where the
untrained human eye expects them. I.e. they're still there, just
hidden a bit better than with the usual binary floating point
representations.

If you don't want rounding errors, don't use float and double.


-- 
Hans-Bernhard Broeker (broeker AT physik DOT rwth-aachen DOT de)
Even if all the snow were burnt, ashes would remain.

- Raw text -


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