home *** CD-ROM | disk | FTP | other *** search
- Path: sparky!uunet!cs.utexas.edu!uwm.edu!caen!saimiri.primate.wisc.edu!ames!olivea!apple!goofy!kip-53.apple.com!chris_russo
- From: chris_russo@gateway.qm.apple.com (Christopher Russo)
- Newsgroups: comp.sys.mac.programmer
- Subject: Re: (Q) Need bit manipulation algorithm
- Message-ID: <34440@goofy.apple.COM>
- Date: 11 Jan 93 21:29:10 GMT
- References: <1993Jan6.022430.19469@leland.Stanford.EDU> <NEERI.93Jan6143512@iis.ethz.ch> <1if329INN2f0@falcon.natinst.com> <1993Jan08.012806.14863@eng.umd.edu>
- Sender: usenet@goofy.apple.COM
- Organization: Apple
- Lines: 20
-
- In article <1993Jan08.012806.14863@eng.umd.edu> Matthew T.
- Russotto,
- russotto@eng.umd.edu writes:
- >>There is a neat trick for counting the number of bits in a
- word that
- >>a Microsoft geek showed me one time. If there are k bits
- with 1's,
- >>it runs in O(k) time.
-
- I learned a cool way in an interview here at Apple. For the
- number of
- bits in a byte, all you'd need is a 256 byte look-up table
- where the
- index designated by, say, 00001010 would be index $A into the
- table which
- would contain the number 2 (that you put there.) It's pretty
- fast.
- -----Christopher Russo
- ----- I admire a clever .sig message. Wish I had one. <sigh>
- ----- day 408.974.6070
-