You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
|
#include "util.h"
|
|
|
|
int bitpop(uint8_t bits)
|
|
{
|
|
int c;
|
|
for (c = 0; bits; c++)
|
|
bits &= bits -1;
|
|
return c;
|
|
}
|
|
|
|
int biton(uint8_t bits)
|
|
{
|
|
int n = 0;
|
|
if (bits >> 4) { bits >>= 4; n += 4;}
|
|
if (bits >> 2) { bits >>= 2; n += 2;}
|
|
if (bits >> 1) { bits >>= 1; n += 1;}
|
|
return n;
|
|
}
|