On 21 December 2015 at 16:40, Volker Braun <vbraun.n...@gmail.com> wrote:
> Just to point out the obvious: In Mathematics, "inverting an integer" means
> 1/x

Of course it does but no mathematician would ever write that in notation as ~x.

>
> Though if you want to work with Python ints nothing is stopping you...
>
> sage: ~2r
> -3
> sage: ~int(2)
> -3
> sage: ~2
> 1/2
> sage: ~ZZ(2)
> 1/2
>
> On Monday, December 21, 2015 at 5:22:20 PM UTC+1, Mark Bell wrote:
>>
>> 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.
>>
>> 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. 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.

-- 
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.

Reply via email to