+ 5

Explain me how does bitwise unsigned right shift operator works. ??

explain me https://code.sololearn.com/cw4k2w2j4NLc/?ref=app

26th Jul 2017, 5:00 PM
Jay Chheda
Jay Chheda - avatar
4 odpowiedzi
+ 2
I found a solution: Mathematically, a left-shift is a *=2, 2 left-shifts is a *=4 and so on. A right-shift is a /= 2 and so on.
1st Aug 2017, 5:59 AM
Brian
Brian - avatar
+ 1
@stanly please...do you mean, left is you multiply by 2 and retain the result.. and right is divide and retain the answer?? can you give a more elaborate.. with eg..
1st Aug 2017, 6:36 AM
Otumian Empire
Otumian Empire - avatar
0
Good question. I also don't understand how does it work. Not only right shift, but also a left one.
26th Jul 2017, 7:42 PM
Brian
Brian - avatar
0
That works for unsigned/positive numbers but I dont get it when there is a negative number because then there is a roll over to positive value.
1st Aug 2017, 6:12 AM
Gurpreet Singh
Gurpreet Singh - avatar