Re: Counting bits by formula?

Jens.Toerring_at_physik.fu-berlin.de
Date: 09/29/04


Date: 29 Sep 2004 18:39:16 GMT

Thomas G. Marshall <tgm2tothe10thpower@replacetextwithnumber.hotmail.com> wrote:

> I've often wondered is there a way of counting the 1 bits in an integer of
> whatever bit-width by formula, that is, /not/ by looping and testing? And
> /without/ an exhaustive boolean expression testing each value (or bit)
> individually.

> Using arithmetic, bitwise, even boolean operators is ok, just so long as it
> isn't doing the "obvious" test of every bit individually.

> I'm /not/ looking for something bitwise exhaustive of this form (in any
> language that would support it):

> !!(num & 128) + !!(num & 64) + ...etc.

> Any ideas?

Would look-up tables do after splitting the integer into chunks
fitting the size of the table?
                                   Regards, Jens

-- 
  \   Jens Thoms Toerring  ___  Jens.Toerring@physik.fu-berlin.de
   \__________________________  http://www.toerring.de


Relevant Pages

  • Re: splitting message without envelop
    ... What is your goal in splitting the file into smaller chunks? ... You might consider doing the splitting in an orchestration (see ... > doing one customer node at a time. ...
    (microsoft.public.biztalk.general)
  • Re: Bulk Insert Data in Millions - Lock Issue
    ... My DBA says that splitting the insert statement into smaller chunks ... Prev by Date: ...
    (comp.databases.ms-sqlserver)
  • Re: Total # of Pages
    ... For the sake of your printer, ... might be worthwhile splitting it into even more chunks. ... can't imagine anyone reading all that or how they would find ...
    (microsoft.public.access.reports)
  • Re: Cancel Sub-Irps within a complete routine
    ... into 512KB chunks. ... USBD can do this splitting for you. ... He may still need Win2K compatibility, where the max transfer size made ...
    (microsoft.public.development.device.drivers)
  • Re: How to transfer multiple files in multiple process at the same time
    ... > I have a big file which I split into two or more depending upon the date in 50mb chunks ... > The splitting and joining part works fine. ...
    (microsoft.public.dotnet.languages.vb)