floating point multiplication BUG in C (cc compiler)

Richard A. O'Keefe ok at goanna.cs.rmit.oz.au
Wed Oct 24 14:57:12 AEST 1990


In article <1990Oct23.191109 at osf.org>, dbrooks at osf.org (David Brooks) writes:
: In article <4032 at goanna.cs.rmit.oz.au>, ok at goanna.cs.rmit.oz.au (Richard A. O'Keefe) writes:
: |> The problem here is that a number like 0.64 *CANNOT* *POSSIBLY* be
: |> represented exactly in (finite-precision) floating-point.  At all.
: |> In *any* programming language.  Any compiler, any string->fp converter,
: |> is going to have to round nearly every number there is (only numbers
: |> which are an integer times a power of 2 are likely to be exact); some
: |> of them will round up and some of them will round down.

: Unless, of course, you are blessed with hardware that uses base 10 for
: its floating point.  You are assuming as much about the internal
: representation of floating numbers as the original poster was.

Yes of *course* I was, because I was responding to the original poster.
It's *his* hardware that counts, not some other hardware.
It's his *software* that counts, too, not some other software.
The original poster was complaining about what he thought was a bug
in the C compilers available to him on the machines available to him.
Those are the compiler and machine combinations that count when
responding.  If he had told us exactly which machines he was using,
I'd have responded in terms of the FP formats of those specific machines.
That's what he needed to know about.  How would it help him to hear that
some other kind of machine would do the job (B1800, and I think the
B4800 as well, provided the program was rewritten in Fortran or Cobol)?

I am amazed at the number of E-letters I've received from people who
took it for granted that because I responded to the original poster
in terms relevant to his query that I am ignorant of bignums, rationals,
decimal floats, bigfloats, and the like.  In each case I have implemented
or been associated with the implementation of such things.  They are of
little interest to Joe Beginner trying to figure out how to use 'float'
with C compiler X on machine Y.  (A C++ programmer, now that's a
different story.)

-- 
Fear most of all to be in error.	-- Kierkegaard, quoting Socrates.



More information about the Comp.lang.c mailing list