1. Hey Guys, can i have a hand with this question. I just want to know if what I did was right.

Bit masking has a task. They are used in order to access specific bits in a byte of data.

1) Using the 8-bit binary number “1001 1101”:
Turn off the 2 bits (masking bits to 0) on each side, and then leave the middle 4 alone.The output should be achieved should be "0001 1100”.

2) Using the 8-bit binary number “1001 1101”:
Toggle the values of the middle 4 bits (the opposite of what it currently is), and leave the 2 bits on each side untouched.The output achieved should be"10100001”.

1) (1001 1101) & (0101 1110) = 0001 1100
2) (1001 1101) ^ (0111 1110) = 1010 0001

2. Originally Posted by HELPMEHELPME
1) Using the 8-bit binary number “1001 1101”:
Turn off the 2 bits (masking bits to 0) on each side, and then leave the middle 4
alone.
Originally Posted by HELPMEHELPME
Toggle the values of the middle 4 bits (the opposite of what it currently is), and leave the 2 bits on each side untouched.
Why do these quotes talk about the middle 4 bits and the 2 bits on each side, that is, 6 bits in total, when the input number consists of 8 bits?

Im not sure, its how my teacher wrote the problem. Is there something wrong with it?

4. Originally Posted by HELPMEHELPME
Bit masking has a task. They are used in order to access specific bits in a byte of data.

1) Using the 8-bit binary number “1001 1101”:
Turn off the 2 bits (masking bits to 0) on each side, and then leave the middle 4 alone.The output should be achieved should be "0001 1100”.
0011 1100
.
Using this mask we can do:
1001 1101 &
0011 1100
= 0001 1100

Quote:
2) Using the 8-bit binary number “1001 1101”:
Toggle the values of the middle 4 bits (the opposite of what it currently is), and leave the 2 bits on each side untouched.The output achieved should be"10100001”.
1001 1101 ^
0011 1100
= 1010 0001

Quote:
2) (1001 1101) ^ (0111 1110) = 1010 0001
I'm afraid the xor operator is not evaluated properly here.

Originally Posted by Evgeny.Makarov
Why do these quotes talk about the middle 4 bits and the 2 bits on each side, that is, 6 bits in total, when the input number consists of 8 bits?
Originally Posted by HELPMEHELPME
Im not sure, its how my teacher wrote the problem. Is there something wrong with it?
No.
2 bits on each side means 2 bits to the left and 2 bits to the right, for 2+4+2=8 bits in total.

5. Originally Posted by I like Serena
2 bits on each side means 2 bits to the left and 2 bits to the right, for 2+4+2=8 bits in total.
Of course. Sorry about my misunderstanding.