64bit count leading 0's in c rev2: added attribution, fixed comments
//Count Leading Zeros (CLZ)
//Adapted from Wikipedia: http://en.wikipedia.org/wiki/Find_first_set#Algorithms
int clz (uint64_t x) {
uint64_t t;
int r;
if (x == 0)
return 0;
t = 0x8000000000000000; //mask
r = 0; //number of zeros counter
while ((x & t) == 0 && r < 64) {
t = t >> 0x1;
r ++;
}
return r;
}