Twiddling.xs

filter: Statementstmt 100% 13 / 13 Branchbran 100% 4 / 4 Conditioncond n/a MC/DCmcdc n/a Subroutinesub n/a Podpod n/a totaltotal 100% 17 / 17 CC 0 SCAR 0
CC
0
Cov
0%
CRAP 0
↑ Summary blib/lib/Bit/Twiddling.pm »
1 #include "EXTERN.h"
2 #include "perl.h"
3 #include "XSUB.h"
4  
5 9 int count_set_bits(long v) {
6 int c;
7 79 ▶ for (c = 0; v; c++)
Branch: 1 branch
BranchTrueFalseTotal
for (c = 0; v; c++) 70 9 79
8 70 v &= v - 1;
9 9 return c;
10 }
11  
12 10 long nearest_higher_power_of_2(long v) {
13 10 ▶ if (v == 0) return 1;
Branch: 1 branch
BranchTrueFalseTotal
if (v == 0) return 1; 4 6 10
14 6 v--;
15 6 v |= v >> 1;
16 6 v |= v >> 2;
17 6 v |= v >> 4;
18 6 v |= v >> 8;
19 6 v |= v >> 16;
20 6 return v + 1;
21 }
22  
23 MODULE = Bit::Twiddling PACKAGE = Bit::Twiddling
24  
25 PROTOTYPES: DISABLE
26  
27 int
28 count_set_bits (v)
29 long v
30  
31 long
32 nearest_higher_power_of_2 (v)
33 long v
↑ Summary blib/lib/Bit/Twiddling.pm »