title: Python >> Operator returns different output than in javascript >>>
body: <pre><code>a = -506298134 
  d = 6
  d = a &gt;&gt; d &amp; 0xFFFFFFFF
  d = twos_comp(d, 32)
  
  def twos_comp(val, bits):
      """compute the 2's complement of int value val"""
      if (val &amp; (1 &lt;&lt; (bits - 1))) != 0: # if sign bit is set e.g., 8bit: 128-255
          val = val - (1 &lt;&lt; bits)        # compute negative value
      return val
  </code></pre>
  
  <p>d returns me following <code>-7910909</code></p>
  
  <p>In Javascript</p>
  
  <pre><code>a = -506298134 
  d = 6
  d = a &gt;&gt;&gt; d &amp; 0xFFFFFFFF
  </code></pre>
  
  <p>d returns <code>59197955</code></p>
  
  <p>What can I do different to return the same value as javascript in python?</p>