In Python for an integer x, its invert ~x is defined to be its two-complement <https://wiki.python.org/moin/BitwiseOperators> and is given by -1-x.
On the other hand, in Sage Integers (from sage.rings.integer.Integer) have their __invert__ defined to be 1 / self <https://github.com/sagemath/sage/blob/master/src/sage/rings/integer.pyx#L5999-L6011> . Unfortunately this difference is cause several of my Python scripts to crash / behave differently. Most notably that under this definition ~0 raises a "ZeroDivisionError: Rational division by zero" error. Looking through the git history it appears that this has been the way integers that have been inverted since at least October 2006 <https://github.com/sagemath/sage/blob/b94db547579596d7979e28aa9aff1cdb45193bcc/src/sage/rings/integer.pyx#L1590-L1593>. Why do sage Integers not use the "standard" Python invert? -- You received this message because you are subscribed to the Google Groups "sage-devel" group. To unsubscribe from this group and stop receiving emails from it, send an email to sage-devel+unsubscr...@googlegroups.com. To post to this group, send email to sage-devel@googlegroups.com. Visit this group at https://groups.google.com/group/sage-devel. For more options, visit https://groups.google.com/d/optout.