| www.delorie.com/archives/browse.cgi | search |
| Message-ID: | <37B57FBB.710B3456@unb.ca> |
| From: | Endlisnis <s257m AT unb DOT ca> |
| X-Mailer: | Mozilla 4.61 [en] (Win98; 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> <37B48ABE DOT 110D2C13 AT intel DOT com> <37B4D8BC DOT 6465 AT ns DOT sympatico DOT ca> |
| Lines: | 27 |
| Date: | Sat, 14 Aug 1999 14:41:01 GMT |
| NNTP-Posting-Host: | 209.226.124.241 |
| X-Trace: | news21.bellglobal.com 934641661 209.226.124.241 (Sat, 14 Aug 1999 10:41:01 EDT) |
| NNTP-Posting-Date: | Sat, 14 Aug 1999 10:41:01 EDT |
| Organization: | Sympatico |
| To: | djgpp AT delorie DOT com |
| DJ-Gateway: | from newsgroup comp.os.msdos.djgpp |
| Reply-To: | djgpp AT delorie DOT com |
Klaas wrote:
> > int
> > Ones(unsigned long mask)
> > {
> > register unsigned long y;
> >
> > y = (mask >> 1) & 033333333333;
> > y = mask - y - ((y >>1) & 033333333333);
> > return (int) (((y + (y >> 3)) & 030707070707) % 077);
> > }
> >
> > Regards,
> > Kurt Alstrup
> Doesn't the modulo make it rather slow?
Hopefully, the compiler would replace that with "& ~077", but it probably
should be changed to that just in case...
--
(\/) Endlisnis (\/)
s257m AT unb DOT ca
Endlisnis AT HotMail DOT com
ICQ: 32959047
| webmaster | delorie software privacy |
| Copyright © 2019 by DJ Delorie | Updated Jul 2019 |