Talk:Arithmetic shift
From Wikipedia, the free encyclopedia
When multiplying a negative number written using the one's complement convention, 1, and not 0, should be inserted into the LSB. A clear example of this is 1101 (-2). When left-shifted as described in the article, it'd become 1010 (-5). However, if 1 is put into the LSB, it becomes 1011(-4), the correct answer. So actually, when using one's complement, the signal bit should be reinserted into the LSB after the shift. Budsbd 14:30, 6 March 2007 (UTC)
On arithmetic right shift equivalence to division:
It is stated that arithmetic right shift is not equivalent to division by a power of two, but this is only the case if division of negative rounds towards zero; if on a particular machine division rounds towards negative infinity, the right shift is equivalent.
Also, it is stated that this non-equivalence is the reason C doesn't specify right shift behavior of a negative value. From my understanding, the real reason is simply that right shifts of signed positive integers are common, and some hardware doesn't natively support arithmetic right shifts (only logical, which fills the sign bit with zero), so requiring sign preservation would hurt efficiency on these machines. For the same reason, C doesn't specify the rounding direction when a negative value is divided. C's philosophy is generally to provide what the underlying hardware does (int sizes for example), so >> maps to whatever is provided. -- A reader —Preceding unsigned comment added by 66.90.245.211 (talk) 18:23, 2 February 2008 (UTC)
[edit] Shifts in Scheme
I added a footnote on how shifts work in Scheme, as I think it is interesting to show that Shifts do not have to be operators and that a hybrid approach is possible (shift left, right and in any way depending on the operator). --88.217.68.206 (talk) 23:44, 18 May 2008 (UTC)

