Path: utzoo!mnetor!uunet!seismo!sundc!pitstop!sun!amdcad!ames!hao!gatech!purdue!i.cc.purdue.edu!j.cc.purdue.edu!pur-ee!iuvax!bsu-cs!dhesi From: dhesi@bsu-cs.UUCP (Rahul Dhesi) Newsgroups: comp.lang.c Subject: Re: Another way (How not to write a loop) Message-ID: <2150@bsu-cs.UUCP> Date: 18 Feb 88 17:27:59 GMT References: <1988Feb11.200149.25172@sq.uucp> <2550046@hpisod2.HP.COM> Reply-To: dhesi@bsu-cs.UUCP (Rahul Dhesi) Organization: CS Dept, Ball St U, Muncie, Indiana Lines: 27 >> > Floating point numbers should never be used for counting. >> Never say never....At least one >> widely-used implementation of Snobol4 successfully uses a floating >> point register to count the number of statements executed... >We have a misunderstanding of the word "should", apparently. There might be confusion between "should not" and "should never". Floating point numbers should not be used for counting except when such use gains us a remarkable degree of badly-needed efficiency. In the Snobol (actually SPITBOL) example, the choice was between the equivalents of the following: count -=1; /* integer arithmetic with software test */ if (count == 0) abort_program; and count +=x; /* fast hardware floating add */ /* actually AUR SCNT,SINC on IBM 360 */ Note that the language required one or the other of the above to be done before every statement executed. -- Rahul Dhesi UUCP: !{iuvax,pur-ee,uunet}!bsu-cs!dhesi