public void Test_BitCount_Int64() { assertEquals(0, BitOperation.PopCount(0x0L)); assertEquals(1, BitOperation.PopCount(0x1L)); assertEquals(1, BitOperation.PopCount(0x2L)); assertEquals(2, BitOperation.PopCount(0x3L)); assertEquals(1, BitOperation.PopCount(0x4L)); assertEquals(2, BitOperation.PopCount(0x5L)); assertEquals(2, BitOperation.PopCount(0x6L)); assertEquals(3, BitOperation.PopCount(0x7L)); assertEquals(1, BitOperation.PopCount(0x8L)); assertEquals(2, BitOperation.PopCount(0x9L)); assertEquals(2, BitOperation.PopCount(0xAL)); assertEquals(3, BitOperation.PopCount(0xBL)); assertEquals(2, BitOperation.PopCount(0xCL)); assertEquals(3, BitOperation.PopCount(0xDL)); assertEquals(3, BitOperation.PopCount(0xEL)); assertEquals(4, BitOperation.PopCount(0xFL)); assertEquals(8, BitOperation.PopCount(0xFFL)); assertEquals(12, BitOperation.PopCount(0xFFFL)); assertEquals(16, BitOperation.PopCount(0xFFFFL)); assertEquals(20, BitOperation.PopCount(0xFFFFFL)); assertEquals(24, BitOperation.PopCount(0xFFFFFFL)); assertEquals(28, BitOperation.PopCount(0xFFFFFFFL)); assertEquals(64, BitOperation.PopCount(unchecked ((long)0xFFFFFFFFFFFFFFFFL))); }
public void Test_BitCount_Int32() { assertEquals(0, BitOperation.PopCount(0x0)); assertEquals(1, BitOperation.PopCount(0x1)); assertEquals(1, BitOperation.PopCount(0x2)); assertEquals(2, BitOperation.PopCount(0x3)); assertEquals(1, BitOperation.PopCount(0x4)); assertEquals(2, BitOperation.PopCount(0x5)); assertEquals(2, BitOperation.PopCount(0x6)); assertEquals(3, BitOperation.PopCount(0x7)); assertEquals(1, BitOperation.PopCount(0x8)); assertEquals(2, BitOperation.PopCount(0x9)); assertEquals(2, BitOperation.PopCount(0xA)); assertEquals(3, BitOperation.PopCount(0xB)); assertEquals(2, BitOperation.PopCount(0xC)); assertEquals(3, BitOperation.PopCount(0xD)); assertEquals(3, BitOperation.PopCount(0xE)); assertEquals(4, BitOperation.PopCount(0xF)); assertEquals(8, BitOperation.PopCount(0xFF)); assertEquals(12, BitOperation.PopCount(0xFFF)); assertEquals(16, BitOperation.PopCount(0xFFFF)); assertEquals(20, BitOperation.PopCount(0xFFFFF)); assertEquals(24, BitOperation.PopCount(0xFFFFFF)); assertEquals(28, BitOperation.PopCount(0xFFFFFFF)); assertEquals(32, BitOperation.PopCount(unchecked ((int)0xFFFFFFFF))); }