"for" loops (was Re: C++ vs. Modula2)

John Woods john at frog.UUCP
Mon Jan 30 16:57:00 AEST 1989


In article <19579 at agate.BERKELEY.EDU>, bowles at eris.berkeley.edu (Jeff A. Bowles) writes:
>    If I had a nickel for every time, in Fortran,
>    that I needed a loop that ran from 0.0 to 1.0 by 0.1 (or the like)
...you'd be broke.  You NEVER need a loop that runs from 0.0 to 1.0 by 0.1.
1/10 is a repeating fraction in binary, and thus .1+.1+.1+.1+.1+.1+.1+.1+.1+.1
does NOT equal 1.0.  Read "The Elements of Programming Style" for more tidbits
on this and other programming topics.
-- 
John Woods, Charles River Data Systems, Framingham MA, (508) 626-1101
...!decvax!frog!john, john at frog.UUCP, ...!mit-eddie!jfw, jfw at eddie.mit.edu

Presumably this means that it is vital to get the wrong answers quickly.
		Kernighan and Plauger, The Elements of Programming Style



More information about the Comp.lang.c mailing list