Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

For the following three questions, remember that bit numbers start numbering fro

ID: 3710089 • Letter: F

Question

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.

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.

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.

Explanation / Answer

42) &0010 := & 0000 0000 0001 0000

And a number with above mask(5th bit set as 1 and all the others set as 0). In 5th bit of number is 1 then anding with 5th bit of mask which is 1 will result in 1 otherwise 0.

43) &11E1 := 1111 1111 1110 1111

Since 5th bit in mask is 0, when anded with number's 5th bit(whether 1 or 0) will always result in 0.

44) |0010:= 0000 0000 0001 0000

To set 5th bit of number to 1, 5th bit in the mask should be set to 1 for OR operation so that whether original is 0 or 1, Or with 1 will always result in 1.