count of bits set in a long
David Brooks
dbrooks at osf.osf.org
Tue Sep 25 12:44:39 AEST 1990
In article <37545 at ut-emx.uucp> nwagner at ut-emx.uucp (Neal R. Wagner) writes:
>
> I need a fast method to count the number of bits that are set in a 32-bit
>integer on a Sun 3/80 running 4.0.3 SunOS.
I wish people who aren't using the net to do their homework, but look
as though they are, would say so.
>Is there a faster way in C? How close in speed to a hand-coded assembly
>routine would a fast method in C be (after the latter is run through the
>optimizer)?
Well, if you don't restrict youself to the Sun3, I once knew a machine
that could do it in one instruction. I doubt if any compiler could
compile your code into that.
--
David Brooks dbrooks at osf.org
Systems Engineering, OSF uunet!osf.org!dbrooks
"A Loaf of Bread, a Jug of Wine, and Six Spades Redoubled -- Omar somebody.
More information about the Comp.lang.c
mailing list