UINT8 Calc_1_Number(UINT32 Val)
{
UINT8 Num = 0;
UINT8 TempVal = Val;
while(TempVal)
{
TempVal &= TempVal - 1;
Num ++;
}
return Num;
}
This is not the fastest algorism.
n&n-1 can get rid of the lowest 1 in a binary integer.