Shift Functions
  There are two main types of Shift function :
  • logical shift
  • arithmetic shift
 
 

(a) Logical Shift.

One bit 'falls off', and a 0 is shifted in.

Examples:

Logical shift RIGHT 01101011
to get 00110101
   
Logical shift RIGHT 10110001
to get 01011000

 

 

Logical shift to the right

Logical shift to the left

 

 

(b) Arithmetic shift.

Similar to a Logical shift, but the sign bit remains unchanged.

Examples:

Arithmetic shift RIGHT 01101011
to get 00110101
   
Arithmetic shift RIGHT 10110000
to get 11011000

Arithmetic shift to the right

Arithmetic shift to the left

 

Generally :

An arithmetic shift to the right is equivalent to dividing by 2.

Generally, a shift to the right of n places is equivalent to dividing by 2n

Eg. Shift to the right 3 places is equivalent to dividing by 23 = 8

An arithmetic shift to the left is equivalent to multiplying by 2.

Generally, a shift to the left of n places is equivalent to multiplying by 2n

Eg. Shift to the left 3 places is equivalent to multiplying by 23 = 8