Learning is not a spectator sport

December 7, 2013

number of set bits

Filed under: Uncategorized — connormcdonald @ 5:34 pm

 

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

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.

Follow

Get every new post delivered to your Inbox.

Join 71 other followers

%d bloggers like this: