//All Rights Reserved
#include <stdio.h>
void bitprint(int num, int base)
{
if (num <= (base - 1))
printf("%d\n", num);
else
{
bitprint(num/base, base);
printf("%d", num%base);
}
}
int bitset(int num, int n)
{
num |= 1<<n;
return num;
}
int bitclear(int num, int n)
{
num &= ~(1<<n);
return num;
}
int main()
{
int a=253;
bitprint(a, 2);
printf("\n");
a=bitset(a, 1);
bitprint(a, 2);
printf("\n");
a=bitclear(a, 5);
bitprint(a, 2);
printf("\n");
return 0;
}
bit operation
最新推荐文章于 2021-09-02 19:26:03 发布