5 ms·
This fails for negative max int, assuming twos compliment, right?
by jayd16 7y ago
This fails for negative max int, assuming twos compliment, right?
- castratikron 7y agoThe GNU __builtin_popcount takes an unsigned int. https://gcc.gnu.org/onlinedocs/gcc/Other-Builtins.html https://gcc.gnu.org/onlinedocs/gcc/Other-Builtins.html
- jayd16 7y agoRight. If he naively casts, it will cast to 2^(int bits size) and return 1 but that's wrong. Its not a complete solution.