Path: utzoo!utgpu!watserv1!watmath!att!att!pacbell.com!ucsd!usc!samsung!munnari.oz.au!goanna!ok From: ok@goanna.cs.rmit.oz.au (Richard A. O'Keefe) Newsgroups: comp.lang.c Subject: Re: floating point multiplication BUG in C (cc compiler) Keywords: bug in C float multiplication Message-ID: <4065@goanna.cs.rmit.oz.au> Date: 24 Oct 90 04:57:12 GMT References: <1348@banach.ACA.MCC.COM> <4032@goanna.cs.rmit.oz.au> <1990Oct23.191109@osf.org> Organization: Comp Sci, RMIT, Melbourne, Australia Lines: 36 In article <1990Oct23.191109@osf.org>, dbrooks@osf.org (David Brooks) writes: : In article <4032@goanna.cs.rmit.oz.au>, ok@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.