Path: utzoo!utgpu!news-server.csri.toronto.edu!cs.utexas.edu!samsung!zaphod.mps.ohio-state.edu!ncar!ico!haddock!karl From: karl@haddock.ima.isc.com (Karl Heuer) Newsgroups: comp.lang.c Subject: Re: count of bits set in a long Keywords: bits set, count of, long Message-ID: <18389@haddock.ima.isc.com> Date: 3 Oct 90 03:43:55 GMT References: <37545@ut-emx.uucp> <1990Sep26.180240.11516@everexn.com> <12330@crdgw1.crd.ge.com> Reply-To: karl@haddock.ima.isc.com (Karl Heuer) Organization: Interactive Systems, Cambridge, MA 02138-5302 Lines: 11 In article <12330@crdgw1.crd.ge.com> davidsen@crdos1.crd.ge.com (bill davidsen) writes: >[Aren't these solutions non-portable?] Didn't the original problem ask for the bit count of "a 32-bit word"? In any case, most of the solutions can be easily configured to use the constants from . (I may have left them out of my solution, for brevity.) The two's complement assumption isn't a problem if you define the argument to be an unsigned type (which it *should* be, if you're doing bit manipulations). Karl W. Z. Heuer (karl@kelp.ima.isc.com or ima!kelp!karl), The Walking Lint