Ticket #4965: 4965-shift-fix.patch

File 4965-shift-fix.patch, 1.0 KB (added by Robert Bradshaw, 14 years ago)
  • sage/rings/polynomial/polynomial_template.pxi

    # HG changeset patch
    # User Robert Bradshaw <robertwb@math.washington.edu>
    # Date 1231997074 28800
    # Node ID 1018082fa889e5ac11e41a5124523e1a26e79f3f
    # Parent  77438f4d276e08f6d9e4328c881854517ca04b1d
    Fix shifting in polynomial_template, discovered in ticket #4965.
    
    diff -r 77438f4d276e -r 1018082fa889 sage/rings/polynomial/polynomial_template.pxi
    a b  
    601601            1
    602602            sage: (x^2 + x)>>1
    603603            x + 1
     604            sage: (x^2 + x) >> -1
     605            x^3 + x^2
    604606        """
    605607        if not PY_TYPE_CHECK(self, Polynomial_template):
    606608            raise TypeError("Cannot %s >> %n."%(self, n))
     
    609611        if n == 0:
    610612            return self
    611613        elif n < 0:
    612             return self >> -n
     614            return self << -n
    613615
    614616        parent = (<Polynomial_template>self)._parent
    615617        cdef cparent _parent = get_cparent(parent)