getbit() function K&R 2.9
getbit() function
#include
#include
int getbit(unsigned number, int position,int width )
{
return(number>>(position+1-width)) & ~(~0<
}
int main ()
{ unsigned int a ;
a = getbit(0xA7,6,4);
printf(" The extracted bit is %d = ", a);
return 0;
getch();
}
No comments:
Post a Comment