Talk:Arithmetic shift

From Wikipedia, the free encyclopedia
Jump to: navigation, search
WikiProject Computing (Rated Start-class, Mid-importance)
WikiProject icon This article is within the scope of WikiProject Computing, a collaborative effort to improve the coverage of computers, computing, and information technology on Wikipedia. If you would like to participate, please visit the project page, where you can join the discussion and see a list of open tasks.
Start-Class article Start  This article has been rated as Start-Class on the project's quality scale.
 Mid  This article has been rated as Mid-importance on the project's importance scale.

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 (talk) 18:23, 2 February 2008 (UTC)

Shifts in Scheme[edit]

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). -- (talk) 23:44, 18 May 2008 (UTC)

Equivalence discussion[edit]

The article rides about the claim that there is no equivalence of shift and multiplication or division before it gets to the issue. This should not be presented drama-style.

The statement "Logical shifts of binary numbers are only equivalent to division by a power of 2 when the ones' complement representation of signed numbers is being used, for example." lacks explanation, esp. since logical shifts are not applicable to the interpretation of a word as a negative number; I vaguely feel this statement is just nonsense because for a negative number, a logical shift would make it positive in any complement.


The suggested transition from "older ones' complement architectures to newer two's complement architectures" is not historically correct; the first working digital computer (Zuse Z3) did use the 2's complement. — Preceding unsigned comment added by Towopedia (talkcontribs) 15:41, 6 September 2012 (UTC)

Left shift not correct?[edit]

The arithmetic left shift diagram appears to be incorrect. It shows the second-most-significant bit being copied into the most-signficant bit. In C (C99) and C++ (11) the result of left shifting a negative signed integral type is undefined behavior. C and C++ can thus be said to have no arithmetic left shift; only logical.

However, in the abstract sense, the most-significant bit should be preserved (+3 becomes +6 and -2 becomes -4). An overflow happens if the most-significant bit is different from any of the N next most significant bits, whether positive or negative. For the diagram to apply to the abstract logical situation, all those bits disappear and MSB remains the same. Anything else is a technical detail dependent on the platform or language. Casu Marzu (talk) 17:51, 30 September 2013 (UTC)

The first picture depicts LOGICAL SHIFT in ARITHMETIC SHIFT[edit]

The first pic & its caption ( doesn't go with the text in the Main section of Arithmetic Shift. Please

  • remove the first picture


  • change its caption stating that it is infact a logic shift operation and is given to differentaite between the two shifts

The caption says "A left arithmetic shift of a binary number by 1..." but it is seen as a "logical shift" as the new bit is filled with zero and not the replicated last bit. — Preceding unsigned comment added by (talk) 05:36, 27 October 2013 (UTC)