Tom Pohl added the comment:

Thanks for all the explanations why Python's floor division (FD) works as 
specified. And I agree, it does work as specified, but still, I think this is 
not the behavior that most people would expect and is therefore dangerous to 
provide/use.

What do I expect from FD (x//y):
1. Perform a division (I don't care about the details here).
2. Return an integer value q (even if it's stored in a float).
3. The absolute difference between the mathematical division q'=x/y and the 
returned result q is less than 1, since it's just a floor operation, right?

1//0.1 = 9.0 violates my personal last expectation and I guess I'm not the only 
one.

My use case: I need to perform a division, but the method only accepts integer 
values, so what I used to do is FD. Since today I'm using int(x/y) or 
floor(x/y).

----------

_______________________________________
Python tracker <rep...@bugs.python.org>
<http://bugs.python.org/issue16460>
_______________________________________
_______________________________________________
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com

Reply via email to