Are the floating point routines on my machine broken?
Joseph S. D. Yao
jsdy at hadron.UUCP
Fri Jan 2 22:50:28 AEST 1987
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 at seismo.{CSS.GOV,ARPA,UUCP}
jsdy at hadron.COM (not yet domainised)
More information about the Comp.lang.c
mailing list