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 interestedin algos/math...]
- From: Gerald Pfeifer <pfeifer at dbai dot tuwien dot ac dot at>
- To: Vivek Srivastava <u2000159 at cs dot unipune dot ernet dot in>
- Cc: Preeti Aira <ms_preeti at hotmail dot com>, <gcc-help at gcc dot gnu dot org>, <gcc at gcc dot gnu dot org>
- Date: Thu, 25 Apr 2002 09:37:21 +0200 (CEST)
- Subject: Re: Number of 1's in 64 bit number...[don't read if not interestedin algos/math...]
On Thu, 25 Apr 2002, Vivek Srivastava 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.
> I don't know why do you ask for an algo without any loops or recursion. As
> far as I can see, it cannot be done without them.
Of course you can! Any problem with bounded input size can be trivially
implemented without loops or recursion (though code size will increase
with O(...)).
However, this kind of questions is *not* the scope of this mailing list
which is about developing GCC, not developing *with* GCC!
Gerald
--
Gerald "Jerry" pfeifer@dbai.tuwien.ac.at http://www.dbai.tuwien.ac.at/~pfeifer/