Bit Operations

Apr 2015
6
0
Singapore
Hey Guys, can i have a hand with this question its difficult for me.

Bit mask
ing has a task. They are used in order to access specific bits in a byte of data.
Using the 8-bit binary number “1001 1101”:

  1. 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. Toggle the values of the middle 4 bits (the opposite of what it currently is), and leavethe 2 bits on each side untouched.The output achieved should be"10100001”.
 
Dec 2012
1,145
502
Athens, OH, USA
You didn't specify what operations are available. If & (and) and ^ (exclusive or) are available, it's easy:
(1001 1101) & (0101 1110) = 0001 1100
(1001 1101) ^ (0111 1110) = 1010 0001
 
  • Like
Reactions: 1 person
Apr 2015
6
0
Singapore
Thanks johng, I enquired and this is the only information i received: "you should find out how to use the most appropriate boolean operators to implement the given".
 
Last edited:
Oct 2012
34
0
Australia
You didn't specify what operations are available. If & (and) and ^ (exclusive or) are available, it's easy:
(1001 1101) & (0101 1110) = 0001 1100
(1001 1101) ^ (0111 1110) = 1010 0001
What is (1111 0000) & (0101 1110) and does it match (0011 000)?
What is (1111 0000) ^ (0111 1110) and does it match (1100 1100)?

Also, just a logical consideration: the outer 4 bits are always supposed to get the same effect (set to 0 in the first case, keep the same in the second case). Can something like (0101 1110) make sense, where different bits in this group are treated differently?