either count it with a for loop or if you are using C, use
__builtin_popcount(int x)

or

x is given
int count = 0;
for(int i=0; i<32;i++) count += (x & (1<<i)) != 0;

On Tue, Aug 3, 2010 at 12:04 PM, amit <[email protected]> wrote:

> (3*4096+15*256+3*16+3). How many 1's are there in the binary
> representation of the result.
>
> Is there a quick way to count the number of set bits in this number
> manually???
>
> --
> You received this message because you are subscribed to the Google Groups
> "Algorithm Geeks" group.
> To post to this group, send email to [email protected].
> To unsubscribe from this group, send email to
> [email protected]<algogeeks%[email protected]>
> .
> For more options, visit this group at
> http://groups.google.com/group/algogeeks?hl=en.
>
>

-- 
You received this message because you are subscribed to the Google Groups 
"Algorithm Geeks" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to 
[email protected].
For more options, visit this group at 
http://groups.google.com/group/algogeeks?hl=en.

Reply via email to