aboutsummaryrefslogtreecommitdiffstats
path: root/include/bit_ops.h
diff options
context:
space:
mode:
Diffstat (limited to 'include/bit_ops.h')
-rw-r--r--include/bit_ops.h4
1 files changed, 2 insertions, 2 deletions
diff --git a/include/bit_ops.h b/include/bit_ops.h
index ec3961dd3..594d130a4 100644
--- a/include/bit_ops.h
+++ b/include/bit_ops.h
@@ -67,8 +67,8 @@ inline u32bit hamming_weight(T n)
0, 1, 1, 2, 1, 2, 2, 3, 1, 2, 2, 3, 2, 3, 3, 4 };
u32bit weight = 0;
- for(u32bit i = 0; i != 8*sizeof(T); i += 4)
- weight += NIBBLE_WEIGHTS[(n >> i) & 0x0F];
+ for(u32bit i = 0; i != 2*sizeof(T); ++i)
+ weight += NIBBLE_WEIGHTS[(n >> (4*i)) & 0x0F];
return weight;
}