Bit Count UInt 32 (method 2) - CSharp System

CSharp examples for System:Int32

Description

Bit Count UInt 32 (method 2)

Demo Code


using System;//  www . j av a  2s.com

public class Main{
    public static int BitCount2( UInt32 n )
      {
         n   = n - ((n >> 1) & 0xDB6DB6DB) - ((n >> 2) & 0x49249249);

         return (int)( ( n + ( n >> 3 ) ) & 0xC71C71C7 ) % 63;
      }
}

Related Tutorials