CSharp examples for System:Int32
Bit Count UInt 32
using System;/*from ww w .j ava 2s . c om*/ public class Main{ public static int BitCount( UInt32 n ) { UInt32 m1 = 0x55555555; UInt32 m2 = 0x33333333; UInt32 m3 = 0x0F0F0F0F; n = (n & m1) + ((n>>1) & m1); n = (n & m2) + ((n>>2) & m2); n = (n & m3) + ((n>>4) & m3); return (int) ( n % 255 ); } }