Arithmetic Shift Functions
Arithmetic Shift Functions
- Arithmetic Shift functions are operations that are used in computer science to manoeuvre (shift) the position of bits in binary numbers.
- There are two main types of Arithmetic Shift: the Arithmetic Shift Left (ASL) and the Arithmetic Shift Right (ASR).
Arithmetic Shift Left (ASL)
- The Arithmetic Shift Left (ASL) operation shifts the bits of a binary number one position to the left.
- During this movement, a 0 is added on the right-side end and the left-most bit is discarded.
- It is important to note that the Arithmetic Shift Left operation effectively multiplies the original number by 2.
Arithmetic Shift Right (ASR)
- On the other hand, the Arithmetic Shift Right (ASR) operation shifts the bits of a binary number one position to the right.
- It fills up the new left-most position with the same value as the bit that was there previously, and the right-most bit gets discarded.
- An Arithmetic Shift Right operation effectively divides the original number by 2, similar to how an Arithmetic Shift Left multiplies it.
Importance of Arithmetic Shifts
- The ASL and ASR operations are critical in computer science as they allow for swift manipulation of binary numbers.
- These operations are much faster than traditional multiplication and division operations, proving instrumental in optimising performance where binary data manipulations are required.
Notation of Arithmetic Shifts
- The notation for ASL can be “b«n” meaning “shift the bits in b left by n places”.
- Precision in noting instructions is crucial, because mistyping or misreading instructions can lead to errors in computing and data manipulation.