AcoustID.Tests.TestsHelper.CountSetBits C# (CSharp) Method

CountSetBits() public static method

public static CountSetBits ( UInt32 v ) : int
v System.UInt32
return int
        public static int CountSetBits(UInt32 v)
        {
            const uint N32 = (uint)~0U;

            v = v - ((v >> 1) & N32 / 3);
            v = (v & N32 / 15 * 3) + ((v >> 2) & N32 / 15 * 3);
            v = (v + (v >> 4)) & N32 / 255 * 15;
            
            return (int)((uint)(v * (N32 / 255)) >> (sizeof(uint) - 1) * 8);
        }

Same methods

TestsHelper::CountSetBits ( System.UInt64 v ) : int