Integer division of rationals

43 views
Skip to first unread message

Nathann Cohen

unread,
Oct 4, 2013, 12:26:26 PM10/4/13
to Sage Support
Helloooooo everybody !

This is what I spent the last hour finding :

sage: x = 1/2
sage: x
1/2
sage: x//2
1/4

I got some variable x as input, which was of rational type when I
expected it to be integer type (does not matter, this rational was
equal to an integer in my case). Unfortunately, x//2 (which I
understand as the integer division of x by 2) does not return an
integer.

Bug or feature ? :-P

Nathann

William Stein

unread,
Oct 4, 2013, 12:41:05 PM10/4/13
to sage-support
*Bug*, because in pure Python, we have

~$ python
Python 2.7.3 (default, Sep 26 2013, 20:03:06)
[GCC 4.6.3] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> 0.5//2
0.0
>>>
~$ python3
Python 3.2.3 (default, Sep 25 2013, 18:22:43)
[GCC 4.6.3] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> 0.5//2
0.0

>
> Nathann
>
> --
> You received this message because you are subscribed to the Google Groups "sage-support" group.
> To unsubscribe from this group and stop receiving emails from it, send an email to sage-support...@googlegroups.com.
> To post to this group, send email to sage-s...@googlegroups.com.
> Visit this group at http://groups.google.com/group/sage-support.
> For more options, visit https://groups.google.com/groups/opt_out.



--
William Stein
Professor of Mathematics
University of Washington
http://wstein.org
Reply all
Reply to author
Forward
0 new messages