Another way (How not to write a loop)
Carl Lowenstein
cdl at mplvax.nosc.MIL
Fri Feb 19 14:11:42 AEST 1988
In article <2150 at bsu-cs.UUCP> dhesi at 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
More information about the Comp.lang.c
mailing list