Relay-Version: version B 2.10 5/3/83; site utzoo.UUCP
Path: utzoo!mnetor!seismo!sundc!netxcom!hadron!jsdy
From: jsdy@hadron.UUCP (Joseph S. D. Yao)
Newsgroups: comp.lang.c,comp.unix.xenix
Subject: Re: Are the floating point routines on my machine broken?
Message-ID: <407@hadron.UUCP>
Date: Fri, 2-Jan-87 07:50:28 EST
Article-I.D.: hadron.407
Posted: Fri Jan  2 07:50:28 1987
Date-Received: Fri, 2-Jan-87 20:59:49 EST
References: <442@catnip.UUCP>
Reply-To: jsdy@hadron.UUCP (Joseph S. D. Yao)
Organization: Hadron, Inc., Fairfax, VA
Lines: 20
Summary: Round-off error, loops, and a subtle Fortran slam.
Xref: mnetor comp.lang.c:580 comp.unix.xenix:37

One of the few values of teaching Fortran to programmers
was that invariably, eventually, students would be taught
about round-off error.  In C, we rarely think that someone
might use a float as a loop control variable.  If one needs
a float value iterated, one should use the old Fortran trick:
	int i;
	float f;

	for (i = 0; i < 30; i += 2) {
		f = i / 10.0;
		...
	}

[Do  n o t  flame me for not using 0:15:1;;f=i/5.0;.  This
 valuation makes it more obvious to the casual reader what
 conversion was done; and the arithmetic is obvious!]
-- 

	Joe Yao		hadron!jsdy@seismo.{CSS.GOV,ARPA,UUCP}
			jsdy@hadron.COM (not yet domainised)