How not to write a loop

Doug Gwyn gwyn at brl-smoke.ARPA
Wed Feb 17 04:51:11 AEST 1988


In article <2115 at bsu-cs.UUCP> dhesi at bsu-cs.UUCP (Rahul Dhesi) writes:
-In article <1988Feb11.200149.25172 at sq.uucp> msb at sq.UUCP (Mark Brader) writes:
->	Floating point numbers should never be used for counting.
-Never say never.  (Well, hardly ever say never.)  At least one
-widely-used implementation of Snobol4 successfully uses a floating
-point register to count the number of statements executed, relying on
-floating point overflow being detected by hardware so that the program
-may be aborted when the user-specified statement count limit is
-reached.

Mark was talking about good style, not what some crufty program
happens to do.  Note that that SNOBOL4 implementation will malfunction
on machines like the Gould PowerNodes where the environment requires
floating-point overflow trapping to be disabled (because, in the case
of the Goulds, the compiler generates code that assumes integer overflow
is benign, and the hardware design stupidly couples the two types of
overflow to the same enable bit).



More information about the Comp.lang.c mailing list