Learning is not a spectator sport

December 7, 2013

number of set bits

Filed under: Uncategorized — connormcdonald @ 5:34 pm


  n number := ....;
  tmp number;
  tmp := n - ( bitand ((n / 2) ,3681400539))
           - (bitand ((n / 4) ,1227133513));
   tmp := mod ( bitand ((tmp + (tmp / 8)) , 3340530119) , 63 );

Google for "hakmem" to see how it works

About these ads

Leave a Comment »

No comments yet.

RSS feed for comments on this post. TrackBack URI

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

The WordPress Classic Theme. Blog at WordPress.com.


Get every new post delivered to your Inbox.

Join 89 other followers

%d bloggers like this: