0% found this document useful (0 votes)
6 views31 pages

Binary Shifts

Uploaded by

whtet6933
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
6 views31 pages

Binary Shifts

Uploaded by

whtet6933
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
You are on page 1/ 31

Binary Shifts

Logical, Arithmetic & Cyclic Shifts


Logical
Logical & Arithmetic Left Shift
Arithmetic
● Each bit is moved one left
● The most significant bit(left most) is discarded
● A zero is added to the right
● repeat for the number of shifts required...

1 0 1 1 0 1 0 1
Logical
Logical & Arithmetic Left Shift
Arithmetic
● Each bit is moved one left
● The most significant bit(left most) is discarded
● A zero is added to the right
● repeat for the number of shifts required...

1 0 1 1 0 1 0 1
Logical
Logical & Arithmetic Left Shift
Arithmetic
● Each bit is moved one left
● The most significant bit(left most) is discarded
● A zero is added to the right
● repeat for the number of shifts required...

1 0 1 1 0 1 0 1

0 1 1 0 1 0 1
Logical
Logical & Arithmetic Left Shift
Arithmetic
● Each bit is moved one left
● The most significant bit(left most) is discarded
● A zero is added to the right
● repeat for the number of shifts required...

1 0 1 1 0 1 0 1

0 1 1 0 1 0 1
Logical
Logical & Arithmetic Left Shift
Arithmetic
● Each bit is moved one left
● The most significant bit(left most) is discarded
● A zero is added to the right
● repeat for the number of shifts required...

1 0 1 1 0 1 0 1

0 1 1 0 1 0 1 0
Logical
Logical & Arithmetic Left Shift
Arithmetic
● Each bit is moved one left
● The most significant bit(left most) is discarded
● A zero is added to the right
● repeat for the number of shifts required...

1 0 1 1 0 1 0 1

0 1 1 0 1 0 1 0
Logical / Arithmetic Left Shift Examples

10110101 01011010
<< 2 << 4
Logical / Arithmetic Left Shift Examples

10110101 01011010
<< 2 << 4
11010100 10100000
Logical
Logical Right Shift
● Each bit is moved one right
● The least significant bit(right most) is discarded
● A zero is added to the left
● repeat for the number of shifts required...

1 0 1 1 0 1 0 1
Logical
Logical Right Shift
● Each bit is moved one right
● The least significant bit(right most) is discarded
● A zero is added to the left
● repeat for the number of shifts required...

1 0 1 1 0 1 0 1
Logical
Logical Right Shift
● Each bit is moved one right
● The least significant bit(right most) is discarded
● A zero is added to the left
● repeat for the number of shifts required...

1 0 1 1 0 1 0 1

1 0 1 1 0 1 0
Logical
Logical Right Shift
● Each bit is moved one right
● The least significant bit(right most) is discarded
● A zero is added to the left
● repeat for the number of shifts required...

1 0 1 1 0 1 0 1

1 0 1 1 0 1 0
Logical
Logical Right Shift
● Each bit is moved one right
● The least significant bit(right most) is discarded
● A zero is added to the left
● repeat for the number of shifts required...

1 0 1 1 0 1 0 1

0 1 0 1 1 0 1 0
Logical Right Shift Examples

10110101 01011010
>> 3 >> 5
Logical Right Shift Examples

10110101 01011010
>> 3 >> 5
00011010 00000010
Arithmetic
Arithmetic Right Shift
● Each bit is moved one right
● The least significant bit(right most) is discarded
● The most significant bit is copied to the left hand side
● repeat for the number of shifts required...

1 0 1 1 0 1 0 1
Arithmetic
Arithmetic Right Shift
● Each bit is moved one right
● The least significant bit(right most) is discarded
● The most significant bit is copied to the left hand side
● repeat for the number of shifts required...

1 0 1 1 0 1 0 1

1 0 1 1 0 1 0
Arithmetic
Arithmetic Right Shift
● Each bit is moved one right
● The least significant bit(right most) is discarded
● The most significant bit is copied to the left hand side
● repeat for the number of shifts required...

1 0 1 1 0 1 0 1

1 0 1 1 0 1 0
Arithmetic
Arithmetic Right Shift
● Each bit is moved one right
● The least significant bit(right most) is discarded
● The most significant bit is copied to the left hand side
● repeat for the number of shifts required...

1 0 1 1 0 1 0 1

1 0 1 1 0 1 0
Arithmetic
Arithmetic Right Shift
● Each bit is moved one right
● The least significant bit(right most) is discarded
● The most significant bit is copied to the left hand side
● repeat for the number of shifts required...

1 0 1 1 0 1 0 1

1 1 0 1 1 0 1 0
Arithmetic Right Shift Examples

10110101 01011010
>> 2 >> 4
Arithmetic Right Shift Examples

10110101 01011010
>> 2 >> 4
11101101 00000101
Cyclic Shift (Left / Right) Cyclic

● Each bit is moved along (left or right)


● The bit that drops off the end is moved to the other end
● No bits are lost

1 0 1 1 0 1 0 1
Cyclic Shift (Left / Right) Cyclic

● Each bit is moved along (left or right)


● The bit that drops off the end is moved to the other end
● No bits are lost

1 0 1 1 0 1 0 1
Cyclic Shift (Left / Right) Cyclic

● Each bit is moved along (left or right)


● The bit that drops off the end is moved to the other end
● No bits are lost

1 0 1 1 0 1 0 1

1 0 1 1 0 1 0
Cyclic Shift (Left / Right) Cyclic

● Each bit is moved along (left or right)


● The bit that drops off the end is moved to the other end
● No bits are lost

1 0 1 1 0 1 0 1

1 0 1 1 0 1 0
Cyclic Shift (Left / Right) Cyclic

● Each bit is moved along (left or right)


● The bit that drops off the end is moved to the other end
● No bits are lost

1 0 1 1 0 1 0 1

1 1 0 1 1 0 1 0
Cyclic Shift Examples

10110101 01011010
>> 2 << 4
Cyclic Shift Examples

10110101 01011010
>> 2 << 4
01101101 10100101
Summary

Logical left
Arithmetic right Cyclic
Arithmetic left

● Move all bits to the left ● Preserves the sign bit ● Move all bits along
● MSB is discarded ● Move all bits to the right ● The bit that falls off one
● Zero is add to the right ● LSB is discarded end is added back to the
● MSB is copied to the left other end

You might also like