Number of 1's in 64 bit number...[don't read if not interested in algos/math...]

Gerald Pfeifer pfeifer@dbai.tuwien.ac.at
Thu Apr 25 04:08:00 GMT 2002


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/



More information about the Gcc-help mailing list