#include<stdio.h>
#define SQR(x) (x*x)
inline int function_SQR(int x) { return x*x;}
#define MASK1 0x01
#define MASK2 0x01<<1
#define MASK3 0x01<<2
#define MASK4 0x01<<3
#define MASK5 0x01<<4
#define MASK6 0x01<<5
#define MASK7 0x01<<6
#define MASK8 0x01<<7
#define MASK2 0x01<<8
#define FUNCTION_BIT_TEST(x,mask) (x)&(mask)
int Function_CountNumber(unsigned short int a );
int Function_CountNumber(unsigned short int a)
{
int count = 0;
bool result;
result = FUNCTION_BIT_TEST(a,MASK1);
if(result)
count++;
result = FUNCTION_BIT_TEST(a,MASK2);
if(result)
count++;
result = FUNCTION_BIT_TEST(a,MASK3);
if(result)
count++;
result = FUNCTION_BIT_TEST(a,MASK4);
if(result)
count++;
result = FUNCTION_BIT_TEST(a,MASK5);
if(result)
count++;
result = FUNCTION_BIT_TEST(a,MASK6);
if(result)
count++;
result = FUNCTION_BIT_TEST(a,MASK7);
if(result)
count++;
result = FUNCTION_BIT_TEST(a,MASK8);
if(result)
count++;
printf("number of 1: %d\n",count);
return count;
}
int main()
{
unsigned short int c = 0;
printf("size of short int %d",sizeof(short));
while(1)
{
printf("input c\n");
fflush(stdin);
scanf("%d",&c);
Function_CountNumber(c);
}
}