VerticallyBehind
New member
- Joined
- Nov 18, 2021
- Messages
- 2
So take the number 4200 for instance, this can be any integer I guess, but let's use that one.
Say I bitshift the value to the right by 1, it then divides the value by 2.
If I were to bitshift the value 4200 to the right by 2, then it would divide it by 4.
If I were to bitshift the value 4200 to the right by 3, then it would divide it by 8.
I understand that it has something to do with the power of 2 and the binary system and the way I look at it is like so
Multiply 2 with the index at the power of 2 table
8 4 2 1
Let's say I wanted to bitshift by 3, I would then take what's on the 3rd index of the table which is the value 4, going from right to left, and multiply it by 2. hence why bitshifting to the right by 3 is the same as dividing by 8.
I don't understand why though, and I don't feel like that would be a good answer if I were to face this on a test. Where the question is.. "Why does it multiply by 8 if you bitshift the value to the right by 3"
Say I bitshift the value to the right by 1, it then divides the value by 2.
If I were to bitshift the value 4200 to the right by 2, then it would divide it by 4.
If I were to bitshift the value 4200 to the right by 3, then it would divide it by 8.
I understand that it has something to do with the power of 2 and the binary system and the way I look at it is like so
Multiply 2 with the index at the power of 2 table
8 4 2 1
Let's say I wanted to bitshift by 3, I would then take what's on the 3rd index of the table which is the value 4, going from right to left, and multiply it by 2. hence why bitshifting to the right by 3 is the same as dividing by 8.
I don't understand why though, and I don't feel like that would be a good answer if I were to face this on a test. Where the question is.. "Why does it multiply by 8 if you bitshift the value to the right by 3"