Add function bitset_popcount
This commit is contained in:
1 parent
5fd6352a4e
commit
7b2e242c94
2 files changed
+41
No files matched your search
@@ -366,6 +366,17 @@ static void test_clz(void)
|
||||
bitset_set_at(s1, 0, false);
|
||||
assert (bitset_clz(s1) == 64+620+1);
|
||||
}
|
||||
|
||||
M_LET(s1, bitset_t) {
|
||||
bitset_set_str(s1, "[00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000]");
|
||||
assert(bitset_popcount(s1) == 0);
|
||||
bitset_set_str(s1, "[10000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000]");
|
||||
assert(bitset_popcount(s1) == 1);
|
||||
bitset_set_str(s1, "[00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000001]");
|
||||
assert(bitset_popcount(s1) == 1);
|
||||
bitset_set_str(s1, "[10000011100000110010101010110000011111111111111110000001110001110001110001110000]");
|
||||
assert(bitset_popcount(s1) == 40);
|
||||
}
|
||||
}
|
||||
|
||||
int main(void)
|
||||
|
||||
Reference in new issue
Block a user