home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1993 #1 / NN_1993_1.iso / spool / comp / sys / mac / programm / 21209 < prev    next >
Encoding:
Internet Message Format  |  1993-01-11  |  1.2 KB

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