Advertisement
Guest User

Untitled

a guest
Aug 18th, 2021
26
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 0.29 KB | None | 0 0
  1. // Write a function that takes an integer as input, and returns the number of bits that are equal to one in the binary representation of that number. You can guarantee that input is non-negative.
  2.  
  3. #include <stddef.h>
  4.  
  5. size_t countBits(unsigned value)
  6. {
  7.     return __builtin_popcountll(value);
  8. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement