Path: utzoo!utgpu!water!watmath!clyde!rutgers!cmcl2!brl-adm!brl-smoke!gwyn From: gwyn@brl-smoke.ARPA (Doug Gwyn ) Newsgroups: comp.lang.c Subject: Re: How not to write a loop Message-ID: <7263@brl-smoke.ARPA> Date: 16 Feb 88 18:51:11 GMT References: <560@naucse.UUCP> <1988Feb11.200149.25172@sq.uucp> <2115@bsu-cs.UUCP> Reply-To: gwyn@brl.arpa (Doug Gwyn (VLD/VMB) ) Organization: Ballistic Research Lab (BRL), APG, MD. Lines: 17 In article <2115@bsu-cs.UUCP> dhesi@bsu-cs.UUCP (Rahul Dhesi) writes: -In article <1988Feb11.200149.25172@sq.uucp> msb@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).