1. Engineering
  2. Computer Science
  3. generally you are not going to and two numbers together...

Question: generally you are not going to and two numbers together...

Question details
Generally, you are not going to AND 
two numbers together that you do or do not know the values of.  Instead,
you will usually take a number you DO NOT know and perform a bitwise
operation on it with a number that you DO know.  The known number above is
called a "mask", because it allows you to selectively observe the values of
just the bits you are interested in.  This can be done to inspect, set, and
flip specific bits in the unknown number. In the following problems, the unknown
number has all X's, and the known number has all 1's and 0's.  Write the
answer.  Each bit of the answer is either 1, 0, or X, where X
is the same bit value as the corresponding bit in the unknown number.

40.) What is
     XXXXXXXX
    |11001010?
40.answer)


41.) What is
     XXXXXXXX
    &10110110?
41.answer)


For the following three questions, remember that bit numbers start
numbering from 0, and that hexadecimal numbers are always unsigned.
In addition to showing the mask you would use, also show the operation
you would use, like so: &0x0020.  (i.e., AND the original number with
the hexadecimal mask 0x0020.)

42.) Specify the mask you would need to inspect bit 5 of the unknown number.
     Express it as a 4-digit hexadecimal number.
42.answer)


43.) Specify the mask you would need to set bit 5 of the unknown number to zero.
     That is, the result of this operation results in a new number, which the unknown
     number should be subsequently set to.  Express it as a 4-digit hexadecimal number.
43.answer)


44.) Specify the mask you would need to set bit 5 of the unknown number to one.
     That is, the result of this operation results in a new number, which the unknown
     number should be subsequently set to.  Express it as a 4-digit hexadecimal number.
44.answer)
Solution by an expert tutor
Blurred Solution
This question has been solved
Subscribe to see this solution