Name: Anonymous 2012-03-18 16:46
Hi
this year i'm going to go on internship to Facebook. Has smb worked there? Any feedback?
this year i'm going to go on internship to Facebook. Has smb worked there? Any feedback?
unsigned sum2(unsigned n) {
unsigned sum = 0;
while (n) {
sum += n&1;
n >>= 1;
}
return sum;
}
unsigned int sum2(unsigned int n){
unsigned int c;
c = ((n & 0xfff) * 0x1001001001001ULL & 0x84210842108421ULL) % 0x1f;
c += (((n & 0xfff000) >> 12) * 0x1001001001001ULL & 0x84210842108421ULL) % 0x1f;
c += ((n >> 24) * 0x1001001001001ULL & 0x84210842108421ULL) % 0x1f;
return c;
}
unsigned int sum2(unsigned int n){
unsigned int c;
for (c = 0; n; c++) n &= n - 1;
return c;
}