2 ms·
Make sure to use __builtin_popcountl to count bits in a uint64_t, or you may miss half of them (yes it happened to me).
by psuter 10y ago
Make sure to use __builtin_popcountl to count bits in a uint64_t, or you may miss half of them (yes it happened to me).
- nightcracker 10y agoI love this example. Even though you are aware how error-prone this is, you still get it wrong. long is 32-bits on GCC 32-bit. So it will still give the wrong result with `uint64_t`. You should be using __builtin_popcountll. (don't get me wrong - you're not stupid, it happened to me too: https://github.com/orlp/libop/issues/1 https://github.com/orlp/libop/issues/1)
- psuter 10y agoGood catch, thanks. (It has been a while since I've been on a 32bit platform.)