Skip to content

Instantly share code, notes, and snippets.

@linzj
Created November 10, 2020 07:51
Show Gist options
  • Select an option

  • Save linzj/6ee15d5842ee5cf688febcc0c5ade463 to your computer and use it in GitHub Desktop.

Select an option

Save linzj/6ee15d5842ee5cf688febcc0c5ade463 to your computer and use it in GitHub Desktop.
test non zero bits
#include <stdio.h>
#include <stdint.h>
#include <stdlib.h>
int main(int argc, char** argv) {
unsigned long long n = strtoull(argv[1], NULL, 0);
while (n != 0) {
int where = __builtin_ctzll(n);
printf("%d bit set.\n", where);
n &= ~(1ULL << where);
}
return 0;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment