[Python-Dev] PEP 238 - The // operator should truncate instead of floor

Lino Mastrodomenico l.mastrodomenico at gmail.com
Wed Aug 29 18:05:19 CEST 2007

2007/8/29, dany <danzat at gmail.com>:
> For some reason, the integer division behaves unexpectedly for negative
> integers.
> Looking deeper in the python PEPs, I saw that division on integers is
> defined as: idiv(a, b) = floor(fdiv(a, b)).
> This non-quotient division leads to some odd results, e.g. Python seems
> to think -3/2+3/2 = -1. This is clearly, and correct me if I'm mistaken
> - wrong.

FAQ: Why does -22 / 10 return -3?


Past discussion:


Also, FYI, TCL and Ruby behave the same way.

Lino Mastrodomenico
E-mail: l.mastrodomenico at gmail.com

More information about the Python-Dev mailing list