gur111 icon

Cound Off Bits Macro

gur111 | PRO | 06/01/19 09:09:00 AM UTC | 0 ⭐ | 584 👁️ | Never ⏰ | []
C |

240 B

|

None

|

0 👍

/

0 👎

#include <stdio.h>
 
#define CODD(x,c)\
{   \
    for(c=0; x>0; x=x>>2){\
        c += x&1;\
    }\
}
 
 
int main(){
    int b = 111111, c; /* 1011 */
    CODD(b,c);
 
    printf("%d\n",c);
    return 0;
}
 
 
 
 
/*
32 16 8 4 2 1
 1  1 * 1 * 1  == 53
*/

Comments