Created
November 10, 2020 07:51
-
-
Save linzj/6ee15d5842ee5cf688febcc0c5ade463 to your computer and use it in GitHub Desktop.
test non zero bits
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #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