www.delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp/1999/08/13/17:49:11

Message-ID: <37B488D4.8318C652@pentek.com>
Date: Fri, 13 Aug 1999 17:06:28 -0400
From: Charles Krug <charles AT pentek DOT com>
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>
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

- Raw text -


  webmaster     delorie software   privacy  
  Copyright © 2019   by DJ Delorie     Updated Jul 2019