Relay-Version: version B 2.10 5/3/83; site utzoo.UUCP Path: utzoo!utgpu!water!watmath!clyde!rutgers!rochester!udel!burdvax!sdcrdcf!trwrb!cadovax!gryphon!greg From: greg@gryphon.UUCP Newsgroups: comp.lang.c Subject: Re: Printing binary (was: Re: Why college?) Message-ID: <2065@gryphon.CTS.COM> Date: Wed, 28-Oct-87 04:24:36 EST Article-I.D.: gryphon.2065 Posted: Wed Oct 28 04:24:36 1987 Date-Received: Sun, 1-Nov-87 01:27:43 EST References: <35@ateng.UUCP> <3194@sol.ARPA> <2783@xanth.UUCP> Reply-To: greg@gryphon.CTS.COM (Greg Laskin) Organization: Trailing Edge Technology, Redondo Beach, CA Lines: 35 In article <1668@spar.SPAR.SLB.COM> hunt@spar.UUCP (Neil Hunt) writes: >In article <2034@gryphon.CTS.COM> greg@gryphon.CTS.COM (Greg Laskin) writes: >>In article <1646@spar.SPAR.SLB.COM> hunt@spar.UUCP (Neil Hunt) writes: >>>This is crying out for recursion: >>> [ recursive solution deleted] >>Why would this cry out to [ recurse ...] > >I knew that someone would ask this. Check out all the stuff that has to happen >to get the binary bits displayed on the screen, or written to a file, and see >if building a new stack frame 31 times is a significant penalty. One of the >basic rules about writing code is only to sacrifice clarity for efficiency >when it will make a difference ! Objectively, the performance penalty is 15-30% (16 bitties on my 286 -- benchmarks available on request) against the recursive solution depending on whether run-time stack checking is performed. Results might/would vary depending on many machine dependent variables. Subjectively, the clarity vs. efficiency question is, in this rather trivial case, probably a matter for the profiler to sort out. Here "all the stuff that has to happen" is relatively small compared to the recursion overhead. More complex "stuff" would flatten out the differences, of course. It's all academic anyway. -- Greg Laskin "When everybody's talking and nobody's listening, how can we decide?" INTERNET: Greg.Laskin@gryphon.CTS.COM UUCP: {hplabs!hp-sdd, sdcsvax, ihnp4}!crash!gryphon!greg UUCP: {philabs, scgvaxd}!cadovax!gryphon!greg