Skip to content

Instantly share code, notes, and snippets.

@Keith-S-Thompson
Created June 12, 2014 20:09
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Keith-S-Thompson/d7260611080f74fab130 to your computer and use it in GitHub Desktop.
Save Keith-S-Thompson/d7260611080f74fab130 to your computer and use it in GitHub Desktop.
#include <stdio.h>
#include <stdint.h>
int main(void) {
int64_t u = 0;
int i;
for(i=0;i<44;i++)
u |= (uint64_t)1 << i;
for(;i<64;i++)
u |= (uint64_t)0 << i;
int t = __builtin_popcountl(u);
printf("u = 0x%llx, t = %d\n", (unsigned long long)u, t);
}
// Output:
// u = 0xfffffffffff, t = 44
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment