Logical Shift (Glossary Entry)

An operation that moves all binary digits a specified number of positions either right or left. 

A Logic Shift simply moves a set of bits right or left. 

A left shift pushes in a zero into the least significant bit position. For an unsigned integer, this is equivalent to a multiplication by 2.

Depicting a logical shift left. Note that a zero is pushed into the least significant bit (right hand side)

A right shift pushes in a zero into the most significant bit position. For an unsigned integer, this is equivalent to a division by 2.

Depicting a logical shift right. Note that a zero is pushed into the most significant bit (left hand side). This is different from an arithmetic right shift.

In C and C++ the logical shift operators << and >> are used as follows: