Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>Bitwise shift operations are not defined for negative values</p> <p>for '&lt;&lt;'</p> <blockquote> <p>6.5.7/4 [...] If E1 has a signed type and nonnegative value, and E1×2<sup>E2</sup> is representable in the result type, then that is the resulting value; otherwise, the behavior is undefined.</p> </blockquote> <p>and for '>>'</p> <blockquote> <p>6.5.7/5 [...] If E1 has a signed type and a negative value, the resulting value is implementation- defined.</p> </blockquote> <p>It's a waste of time to study the behaviour of these operations on signed numbers on a specific implementation, because you have no guarantee it will work the same way on any other implementation (an implementation is, for example, you compiler on your computer with your specific commad-line parameters).</p> <p>It might not even work for an older or a newer version of the very same compiler. The compiler might even define those bits as random or undefined. This would mean that the very same code sequence could produce totally different results when used across your sources or even depend on things like assembly optimisation or other register usage. If encapsulated in a function it might not even produce the same result in those bits on two consecutive calls with the same arguments.</p> <p><strong>Considering only non-negative values</strong>, the effect of left shifting by 1 (<code>expression &lt;&lt; 1</code>) is the same as multpliying the expression by 2 (provided expression * 2 does not overflow) and the effect of right shifting by 1 (<code>expression &gt;&gt; 1</code>) is the same as dividing by 2.</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
    3. VO
      singulars
      1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload