In an arithmetic right shift, each bit in a binary number is shifted to the right by a specified number of . The leftmost bit (the ) is replicated to fill the vacated positions. If the number is positive, are shifted in from the left, while if the number is negative, are shifted in from the left. Arithmetic right shifts are commonly used for division by powers of two in signed integer arithmetic.
In an arithmetic left shift, each bit in a binary number is shifted to the left by a specified number of . The leftmost bit is (shifted out) and zeros are shifted in from the right. Arithmetic left shifts are commonly utilized for multiplication by powers of two in signed integer arithmetic.
For example, starting with the original number 1101 (decimal -3), after performing an arithmetic right shift by 1, the result is 1110 (decimal -2). Conversely, when applying an arithmetic left shift to the same original number, the result becomes 1010 (decimal -6). Arithmetic shifts can dramatically change the value of the binary number based on the direction and type of shift applied.
Keywords
lost | sign bit | ones | positions | zeros | positions |