# Arithmetic shift vs Logical shift

Logical Shift and Arithmetic Shift are two of the most important concept in computer programming. Both are bit manipulation operations (bitwise operations).

An arithmetic shift is a shift operator, sometimes termed a signed shift (though it is not restricted to signed operands).

A logical shift is a bitwise operation that shifts all the bits of its operand.

In this article, we will show you the key differences between Arithmetic shift and Logical shift.

Also check out: Inappropriate ioctl for device/ENOTTY error in Linux

Contents

## Logical Shift

The two base variants of Logical Shift are the logical left shift and the logical right shift.

• Left Logical Shift — Each bit is shifted towards left, MSB is discarded and LSB becomes 0
• Right Logical Shift — Each bit is shifted towards right, LSB is discarded and MSB becomes 0

## Arithmetic Shift

The two basic types of Arithmetic Shift are the arithmetic left shift and the arithmetic right shift.

• Left Arithmetic Shift — Each bit is shifted towards left, MSB is discarded and LSB becomes 0, hence similar to logical shift
• Right Logical Shift — Each bit is shifted towards right, LSB is discarded and MSB becomes 1

## Key Differences between Arithmetic shift vs Logical shift

• Arithmetic shift preserve sign bit, whereas Logical shift can not preserve sign bit.
• Arithmetic shift perform multiplication and division operation, whereas Logical shift perform only multiplication operation.
• Arithmetic shift is used for signed interpretation, whereas Logical shift is used for unsigned interpretation.

We hope that the short article provide helpful information on the differences between Arithmetic shift vs Logical shift. You may want to check out our tutorials on common JavaScript errors such as Unexpected end of JSON input, Not allowed to load local resource, Prettier not working.

If you have any question, don’t hesitate to let us know in the comment section below.