Hi members,
arithmetic shift left in any processor is shifting out msb and adding 0s to lsb. Can it be the same for signed numbers? If so we lose the sign of number?
For ex:if 10001011 is signed number and is arithmetic shifted left by 1 count then the result is 00010110. Havent we lost the sign of number?
Hi members,
arithmetic shift left in any processor is shifting out msb and adding 0s to lsb. Can it be the same for signed numbers? If so we lose the sign of number?
For ex:if 10001011 is signed number and is arithmetic shifted left by 1 count then the result is 00010110. Havent we lost the sign of number?
There are three kinds of shifts, arithmetical, logical, and cyclical.
Logical shift left does what you described, it doesn't preserve the sign bit.
Arithmetical shift keeps the sign bit when shifting left and extends the bit when shifting right.