Encoders
  Home  Forum  Guestbook  Email Us  About Us  Links  More Hub for Computer Whizzes Register to join us

C
C++
Security
Miscellaneous
Encoders > More... > C > Program 16

<< Previous  Next >>


/* Function that gets n bits from postion p. */

#include <stdio.h>

unsigned getbits(unsigned x, int p, int n);

main()
{
        printf("%u\n",getbits(58,4,3));
}

unsigned getbits(unsigned x, int p, int n)
{
        return x>>p+1-n  & ~(~0<<n);
}

 

encoders.20m.com - hosted at 20m.com
Site design and development by Susam Pal
-----------------------------------------------------