negative numbers and integer division

Skip Montanaro skip at pobox.com
Fri Oct 3 15:56:02 EDT 2003


    Mark> I was given the impression that (int // int) was going to be the
    Mark> replacement for (int / int) when (int / int) is changed to return
    Mark> a float, but -1/12 now gives 0, not -1, so (int // int) is not a
    Mark> replacement for (int / int).

>>> from __future__ import division
>>> -1/12
-0.083333333333333329
>>> -1//12
-1

Skip





More information about the Python-list mailing list