I want to use 128-bit unsigned integer in C. I have written the following code:
#include<stdio.h>
#include<stdlib.h>
#include<time.h>
#include<math.h>
#include <stdint.h>
#include <limits.h>
#define unt __uint128_t
#define G1 226854911280625642308916404954512140970
int countSetBits(unt n){
int count = 0;
while(n){ n &= (n-1) ; count++; }
return count;
}
int main(){
printf(" %d\n",countSetBits(G1) );
}
Although output should be 64, number of bits of G1, it is coming 96. I use gcc compiler. I know GMP GNU, but for my purpose, I need fast execution. Hence I want to avoid GNU library.