Ahouxs.123 net.unix-wizards utzoo!decvax!harpo!floyd!vax135!houxi!houxv!houxs!hansen Mon May 3 09:26:30 1982 Re: Re: Caveat Hackor (cc generates bad code for int *= float) Re: `10.0 times 0.1 is hardly ever 1.0' * * Kernighan and Plauger, "The Elements of Programming Style," Second Edition, McGraw-Hill, New York, 1978. Yes, but that is because 0.1 CANNOT be stored as an exact equivalent in any binary base. However, 0.5 (2^-1) CAN be, and multiplying 0.5 times 2 should ALWAYS yield 1.0 in ANY base 2 machine. If you want a floating point counter between 0 and 1.0, everyone (or should, if they've been programming any length of time) knows that 0.125 is much preferable to 0.1. This of course assumes that you are programming on a binary based machine, and not a tertiary or otherwise based machine. (Anyone ever seen one of these?) The real point of the previous note is that the code produced by "i *= f" is supposed to be exactly equivalent in result as "i = i * f." In this case, it is NOT, and is therefore a bug. Sincerely, Tony Hansen ----------------------------------------------------------------- gopher://quux.org/ conversion by John Goerzen of http://communication.ucsd.edu/A-News/ This Usenet Oldnews Archive article may be copied and distributed freely, provided: 1. There is no money collected for the text(s) of the articles. 2. The following notice remains appended to each copy: The Usenet Oldnews Archive: Compilation Copyright (C) 1981, 1996 Bruce Jones, Henry Spencer, David Wiseman.