In an arithmetic right shift, each bit in a binary number is shifted to the right by a specified number of positions. The leftmost bit (the ) is replicated to fill the vacated positions. If the number is , zeros are shifted in from the left. Conversely, if the number is negative, ones are shifted in from the left. Arithmetic right shifts are commonly used for division by powers of two in signed integer .
In an arithmetic left shift, each bit in a binary number is shifted to the left by a specified number of positions. The leftmost bit is lost (shifted out), and zeros are shifted in from the . Arithmetic left shifts are commonly used for multiplication by powers of two in signed integer .
For example, consider the original number 1101 (decimal -3). After performing an arithmetic right shift by 1, the result is 1110 (decimal -2). In contrast, if we perform an arithmetic left shift by 1 on the same original number, the result changes to 1010 (decimal -6). It is important to understand how the sign bit is treated during these and its effect on the final values.
Keywords
arithmetic | sign bit | right | positive | arithmetic | shifts |