This is the mail archive of the
gcc@gcc.gnu.org
mailing list for the GCC project.
Re: Number of 1's in 64 bit number...[don't read if not interested in algos/math...]
- From: Alan Modra <amodra at bigpond dot net dot au>
- To: Preeti Aira <ms_preeti at hotmail dot com>
- Cc: gcc-help at gcc dot gnu dot org, gcc at gcc dot gnu dot org
- Date: Thu, 25 Apr 2002 14:38:23 +0930
- Subject: Re: Number of 1's in 64 bit number...[don't read if not interested in algos/math...]
- References: <F84JlhtUOR2mYfPx9X00000892d@hotmail.com>
On Thu, Apr 25, 2002 at 10:14:02AM +0530, Preeti Aira wrote:
>
> Can any body give me the algo for finding number of 1's (set bits) in a 64
> bit number. Algo with out any loop or recurson. Should be a reasonably
> efficient and small and giving result in fixed time.
You can find such an algorithm in at least two places in the gcc
sources, and also in glibc. You should be able to find it reasonably
easily using grep.
--
Alan Modra
IBM OzLabs - Linux Technology Centre