Re: Counting bits by formula?
Jens.Toerring_at_physik.fu-berlin.de
Date: 09/29/04
- Next message: Jens.Toerring_at_physik.fu-berlin.de: "Re: snarl-snmp error "dereferencing pointer to incomplete type" in function `var_snarl_table'"
- Previous message: Randy: "Re: While studying CS"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
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
- Next message: Jens.Toerring_at_physik.fu-berlin.de: "Re: snarl-snmp error "dereferencing pointer to incomplete type" in function `var_snarl_table'"
- Previous message: Randy: "Re: While studying CS"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Relevant Pages
|