[ 3 / biz / cgl / ck / diy / fa / ic / jp / lit / sci / vr / vt ] [ index / top / reports ] [ become a patron ] [ status ]
2023-11: Warosu is now out of extended maintenance.

/jp/ - Otaku Culture

Search:


View post   

>> No.10227955 [View]
File: 68 KB, 552x521, loop.jpg [View same] [iqdb] [saucenao] [google]
10227955

>>10227835
>>10227846
It is necessary.

And you just want to increment sum when the least significant bit is 1.

unsigned int sum2(int n) {
unsigned int sum = 0;
while (n > 0) {
if ( n & 1) sum++;
n >>= 1;
}
return sum;
}

Navigation
View posts[+24][+48][+96]