Mail Archives: djgpp/1999/09/29/12:39:57
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 -