+ 1
what is 100011 divide by 4 using shifts?
Or perhaps 35 divide by 4? Firstly i need to convert 35 to binary which is 100011 Then divide by 4. But how would i divide the binary number to 4 using shifts? Please help
5 Antworten
+ 3
A right shift by one (>>1) is equivalent to an integer division by 2:
42 = 0b00101010
>> 1 (this shifts all bits to the right by one position):
0b00010101 = 21
25 = 0b00011001
>> 1:
0b00001100 (trailing -1 is lost) => 12
In general, a right shift by x is the same as an integer division by 2^x and a left shift by x the same as a multiplication with 2^x.
In your case, 35>>2 is the same as 35//4 (< integer division). Both are 8.
+ 2
banna101, yes that's correct. You can check the result with 12938//4096 (a//b means: divide a by b, drop all decimal digits).
+ 1
Nevermind haha thank youuu i got itrr
+ 1
Would you mind checking my answer if correct please
So
12938 divide by 4096 using shifts
Would be 11 in binary
Because
2^12 = 4096
12938 in binary is 11001010001010 then >> 11
+ 1
Anna, thank you so much 🙏