Path: utzoo!utgpu!jarvis.csri.toronto.edu!mailrus!eecae!netnews.upenn.edu!rutgers!cmcl2!adm!smoke!gwyn From: gwyn@smoke.BRL.MIL (Doug Gwyn ) Newsgroups: comp.lang.c Subject: Re: "for" loops Message-ID: <9527@smoke.BRL.MIL> Date: 28 Jan 89 04:35:49 GMT References: <19579@agate.BERKELEY.EDU> <8515@lanl.gov> Reply-To: gwyn@brl.arpa (Doug Gwyn (VLD/VMB) ) Organization: Ballistic Research Lab (BRL), APG, MD. Lines: 13 In article <8515@lanl.gov> jlg@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! >This may be another reason for the undesireable feature in C of assuming >double precision as the default floating-point. No, I don't think so. I've never known anyone to recommend a loop like the above. The reasons for defaulting floating-point computations to double precision in original C (no longer required in ANSI C) were that it was easier to support on the PDP-11 that way and that numerical applications were so rare in the UNIX C environment that the potential loss of speed for such applications was not considered significant.