Bitwise Operations to Read ON/OFF Bits

This is a discussion on Bitwise Operations to Read ON/OFF Bits within the C Programming forums, part of the General Programming Boards category; Hey,
I am new to C, and I'm stack on code for bitwise operation
I need to get a function ...

of course this sample lacks checks for suitable range of the second parameter which should be from 1 to CHAR_BITS

the second step will be to take the original value, shift it on X bits left and based on Y-X value - decide what bytes of the number should be passed into the function above with what number of bits too check)

Lets have an example:
Number is 0011001101011100
X = 3
Y = 11
I'm starting at zero as the rightmost binary digit. You didn't give the conventions so I'll make my own. The mask we want is:
0000111111111000

How can we make this mask? Well...
1<<3 == 0000000000001000
1<<11 == 0000100000000000

Now subtract one from those:
0000000000000111
0000011111111111

Can you now see how we can get the mask using 'xor', and then solve the problem using an 'and'?