"for" loops

Jim Giles jlg at lanl.gov
Sun Jan 29 09:54:02 AEST 1989


>From article <9527 at smoke.BRL.MIL>, by gwyn at smoke.BRL.MIL (Doug Gwyn ):
> In article <8515 at lanl.gov> jlg at lanl.gov (Jim Giles) writes:
>>      for (x=0.0; x<=1.0, x+=0.1) {...}
>>For a loop from 0.0 to 1000.0 by 0.01 on a 32-bit floating-point machine,
>>the round-off of the last 100 adds is comparable to the increment itself!
>> [...]
> 
> No, I don't think so.  I've never known anyone to recommend a loop
> like the above.  [...]

I know of at least one person who recommended such a loop - the person
I was originally responding to.  He felt that the above loop was a
clear advantage over what Fortran DO loops could do.  He was wrong
on both counts (Fortran CAN do it and it's not an improvement).

J. Giles



More information about the Comp.lang.c mailing list