Path: utzoo!mnetor!uunet!seismo!sundc!pitstop!sun!decwrl!decvax!ucbvax!ucsd!sdcsvax!sdcc6!mplvax!cdl From: cdl@mplvax.nosc.MIL (Carl Lowenstein) Newsgroups: comp.lang.c Subject: Re: Another way (How not to write a loop) Message-ID: <722@mplvax.nosc.MIL> Date: 19 Feb 88 04:11:42 GMT References: <1988Feb11.200149.25172@sq.uucp> <2550046@hpisod2.HP.COM> <2150@bsu-cs.UUCP> Reply-To: cdl@mplvax.nosc.mil.UUCP (Carl Lowenstein) Organization: U.C. San Diego, Marine Physical Laboratory Lines: 19 In article <2150@bsu-cs.UUCP> dhesi@bsu-cs.UUCP (Rahul Dhesi) writes: > >Floating point numbers should not be used for counting except when such >use gains us a remarkable degree of badly-needed efficiency. > > count -=1; /* integer arithmetic with software test */ > if (count == 0) > abort_program; This is inefficient? I would hope that any decent compiler could turn these lines into the something like (usual case one instruction): / integer arithmetic with hardware test ISZ COUNT / PDP-8 instruction, but even CISC's like JMP ABORT / IBM 7090's and later have an equivalent -- carl lowenstein marine physical lab u.c. san diego {ihnp4|decvax|ucbvax} !sdcsvax!mplvax!cdl