Integer and float division [was Re: Why Python 3?]
Jussi Piitulainen
jpiitula at ling.helsinki.fi
Sun Apr 20 08:38:03 EDT 2014
Steven D'Aprano writes:
> It doesn't round, it truncates.
>
> [steve at ando ~]$ python2.7 -c "print round(799.0/100)"
> 8.0
> [steve at 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 import floor;print floor(799./-100)"
-8.0
$ python2.7 -c "print 799/-100"
-8
$ python3.2 -c "print(799//-100)"
-8
More information about the Python-list
mailing list