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

logical Shiis 0/3 points (graded) Now let\'s also consider logical bit-shifting

ID: 3742921 • Letter: L

Question

logical Shiis 0/3 points (graded) Now let's also consider logical bit-shifting operators for LEFT SHIFTINGand RIGHT SHIFTING). Note that logical left shifting works on both unsigned and signed types, whereas logical right shifting only makes sense for unsigned types. Fill in the blank with the result in terms of an 8-bit binary number (prefix with Ob): ((eb10101010 >3) &0x59)3- Fill in the blank with the simplest numerical expression in terms of x, simple integer arithmetic operators (+,*, and 9%), and numerical Fill in the blank with the simplest numerical expression in terms of x, simple integer arithmetic operators (+,-, *, /, and %), and numerical constants: x >3

Explanation / Answer

The result in terms of an 8-bit binary number
((0b10101010 >> 3) & 0x59) | 3 = 0b00010011

(0b10101010 >> 3) = 0b00010101
(0b10101 & 0x59) = 0b00010001
(0b10001 | 3) = 0b00010011

for numerical value x = 2

x << 4 = 32,

because, the <<, left shift operator shits the contents of operand x, to further 4 decimal places, that results in 32.

x = 0b00000010, x<<4 = 0b00000010 << 4 = 0b00100000

for numerical value x = 2

x >> 3 = 0,

because, the >>, right shift operator. shifts the bits of x to the right, and thus producing the result of 0.