PLEASE SHOW ME YOUR WORKS Imagine that the bits are numbered as: B7 B6 B5 B4 B3
ID: 3619864 • Letter: P
Question
PLEASE SHOW ME YOUR WORKSImagine that the bits are numbered as:
B7 B6 B5 B4 B3 B2 B1 B0
-------------------------------
| 0 | 1 | 0 | 1 | 1 | 0 | 1 | 0 |
-------------------------------
[Part A] If you wanted the Bits B4 and B3 to define a new variable,
how would you manipulate the above byte (called NUM). Hint: apply
a bitwise AND and a shift.
[Part B] Write the code for checking if Bit B6 is set?
[Question 12]
flag1 = 10101110
flag2 = 01101010
flag3 = 11101101
mask1 = flag1 & flag2 & flag3
mask2 = (flag1 | flag2) & flag3
mask3 = (flag1 & flag2) | flag3
Write your answer in binary:
What is the result of mask1?
What is the result of mask2?
What is the result of mask3?
Explanation / Answer
please rate - thanks [Part A] If you wanted the Bits B4 and B3 to define a new variable,how would you manipulate the above byte (called NUM). Hint: apply
a bitwise AND and a shift.
------------------------------- flag1=00011000 newnum=num&flag1
newnum=numnum>3 (shift newnum 3 bits to the right) mask1 = flag1 & flag2 & flag3 mask1=00101010 mask2 = (flag1 | flag2) & flag3 mask2=11101100 mask3 = (flag1 & flag2) | flag3 mask3=11101111