Path: utzoo!attcan!uunet!aplcen!samsung!cs.utexas.edu!usc!julius.cs.uiuc.edu!apple!portal!cup.portal.com!ts From: ts@cup.portal.com (Tim W Smith) Newsgroups: comp.lang.c Subject: Re: count of bits set in a long Message-ID: <34281@cup.portal.com> Date: 26 Sep 90 12:46:35 GMT References: <37545@ut-emx.uucp> <3820@goanna.cs.rmit.oz.au> Organization: The Portal System (TM) Lines: 13 How about something like this? int NumberOfBitsInLong( register unsigned long input ) { register int count; for ( count = 0; input != 0; count++ ) input &= input-1; return count; } Tim Smith