Binary shifting Flashcards
What is binary shifting (bitwise shifting)
A binary shift means moving each bit in the direction defined by the amount defined. Since we work in bytes any bits that go outside our block of 8 are lost forever
Shifting left
Take a 1 byte binary value
e.g 00101000
and shift it left by 2 bits
10100000
Shifting right
Take a 1 byte binary value
e.g 00101000
and shift it right by 3 bits
00000101
what happens when we shift bits right
It halves its value
what happens when we shift bits left
it doubles its value
Shift the following Binary value 2 places to the right:
00111100
00001111
Shift the following Binary value 1 place to the left:
11011001
10110010
Divide the following Binary by 2:
00011101
00001110
Multiply the following Binary value by 8:
00011101
11101000