Note that there are some explanatory texts on larger screens.

plurals
  1. PO.NET equivalent of Java's Integer.bitCount?
    primarykey
    data
    text
    <p>Is there a method similar to Java's <code><a href="http://download.oracle.com/javase/6/docs/api/java/lang/Integer.html#bitCount%28int%29" rel="nofollow noreferrer">Integer.bitCount(int)</a></code> or <code><a href="http://download.oracle.com/javase/6/docs/api/java/lang/Long.html#bitCount%28long%29" rel="nofollow noreferrer">Long.bitCount(long)</a></code> anywhere in the .NET Framework?</p> <p>(For those unfamiliar with these Java methods) this is also known as:</p> <ul> <li><a href="http://en.wikipedia.org/wiki/Hamming_weight" rel="nofollow noreferrer">Hamming Weight</a></li> <li>Population Count (often called <code>POPCNT</code> when implemented in hardware.)</li> </ul> <p>Although <a href="http://www.inwap.com/pdp10/hbaker/hakmem/hacks.html#item167" rel="nofollow noreferrer">there</a> <a href="http://discuss.joelonsoftware.com/default.asp?interview.11.578648.14" rel="nofollow noreferrer">are</a> <a href="https://stackoverflow.com/questions/697978/c-code-to-count-the-number-of-1-bits-in-an-unsigned-char">plenty</a> <a href="http://bits.stephan-brumme.com/countBits.html" rel="nofollow noreferrer">of</a> <a href="http://graphics.stanford.edu/~seander/bithacks.html#CountBitsSetParallel" rel="nofollow noreferrer">implementations</a> <a href="http://www.dotnetperls.com/bitcount" rel="nofollow noreferrer">to</a> <a href="http://gurmeet.net/puzzles/fast-bit-counting-routines/" rel="nofollow noreferrer">be</a> found on the web, I was wondering if there was a standard library implementation.</p> <p>I know this is not in <code>BitArray</code>, <code>UInt32</code> or <code>BitConverter</code>, but maybe there's a version hidden somewhere, e.g. in a crypto function.</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload