Message-ID: <37B488D4.8318C652@pentek.com> Date: Fri, 13 Aug 1999 17:06:28 -0400 From: Charles Krug Organization: Pentek Corporation X-Mailer: Mozilla 4.61 [en] (WinNT; U) X-Accept-Language: en MIME-Version: 1.0 Newsgroups: comp.os.msdos.djgpp Subject: Re: Bit counting? References: <37B45836 DOT EAD7C82D AT swipnet DOT se> Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit NNTP-Posting-Host: mail.pentek.com X-Trace: 13 Aug 1999 17:04:33 -0400, mail.pentek.com Lines: 18 To: djgpp AT delorie DOT com DJ-Gateway: from newsgroup comp.os.msdos.djgpp Reply-To: djgpp AT delorie DOT com Anders David Skarin wrote: > Hi, > > What is the fastest way (or just a damn fast way) to > count the nr of binary 1's in a byte/word/dword ? Look at www.smippets.org. He has a number of routines that work rather well. The basic technique is to have a lookup table--256 long if you have the space, with an entry for each binary value from 0x0 to 0xff. You shift each byte of the quantity into position then find it's entry in the table. Charles