Re: [sage-devel] Inverting Integers gives different behaviour than in Python

2015-12-21 Thread John Cremona
Excellent question. Since ~ is not mathematical notation for anything, outside logic perhaps, does anyone use it at all within Sage? And since all a=5 ~a does is call a.__invert__ which returns one / self, it seems quite a waste of space. Someone might like to add a print statement into that

[sage-devel] Inverting Integers gives different behaviour than in Python

2015-12-21 Thread Mark Bell
In Python for an integer x, its invert ~x is defined to be its two-complement 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