Integer and float division [was Re: Why Python 3?]

2014-04-20 Thread Steven D'Aprano
On Sat, 19 Apr 2014 19:37:31 +1000, Chris Angelico wrote: On Sat, Apr 19, 2014 at 7:25 PM, Ian Kelly ian.g.ke...@gmail.com wrote: The change from / denoting classic division to true division really only affects the case where both operands are integers, so far as I'm aware. If you want to

Re: Integer and float division [was Re: Why Python 3?]

2014-04-20 Thread Jussi Piitulainen
Steven D'Aprano writes: It doesn't round, it truncates. [steve@ando ~]$ python2.7 -c print round(799.0/100) 8.0 [steve@ando ~]$ python2.7 -c print 799/100 7 Seems it floors rather than truncates: $ python2.7 -c from math import trunc;print trunc(799./-100) -7 $ python2.7 -c from math

Re: Integer and float division [was Re: Why Python 3?]

2014-04-20 Thread Steven D'Aprano
On Sun, 20 Apr 2014 15:38:03 +0300, Jussi Piitulainen wrote: Steven D'Aprano writes: It doesn't round, it truncates. [steve@ando ~]$ python2.7 -c print round(799.0/100) 8.0 [steve@ando ~]$ python2.7 -c print 799/100 7 Seems it floors rather than truncates: $ python2.7 -c from math

Re: Integer and float division [was Re: Why Python 3?]

2014-04-20 Thread Gregory Ewing
On Sat, 19 Apr 2014 19:37:31 +1000, Chris Angelico wrote: In Python 3, you have to say Oh but I want my integer division to result in an integer: I don't see why that's such a big hardship. There are clear advantages to having an explicit way to request non-floor division. Whatever way is