6/14: What is the meaning of this statement?

#1

What does this particular statement in the explanation mean?

Shift operations are similar to rounding down after dividing and multiplying by 2 (respectively) for every time you shift??

For example, if the number is 2(0b10), and it is divided by 2 it results in 1 whereas ans is 4.
I can’t make head or tail of this particular statement.

#2

When we shift a binary number to the left it is akin to doubling the number.

``````0b1 * 2 => 0b10       (1 * 2 = 2)
0b10 * 2 => 0b100     (2 * 2 = 4)
0b100 * 2 => 0b1000   (4 * 2 = 8)
``````

Just like when we multiply by 10 we add a zero to the right side, multiplying a binary by 2 we do the same thing. This is a shift left.

When we shift a binary number to the right, we remove the rightmost bit. If it is a 1 bit, then the resulting value will be n / 2, rounded down (floor divided).

``````0b111 / 2 = 0b11 => 7 // 2 = 3

0b11 / 2 = 0b1  => 3 // 2 = 1``````

#3

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.