Hi all

First, some background.
I've recently tried to port a certain library that manipulates dates 
from C. Some of the core functions contain heavy integer math (very long 
formulae), and after implementing them I tested them to see the give the 
desired results.
I got very odd results, which surprised me since I copied the formula 
letter to letter.

I decided to investigate further, and after trying to evaluate several 
expressions in the python console, I realized it was the integer 
division's fault.

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.

Now, seeing as Python 3000 is getting closer, and backwards 
compatibility isn't an issue, I believe it would be a good idea to 
change the // operator (which will be used for integer division) to 
behave as quotient, i.e.: a // b = trunc(a / b)

Dany
_______________________________________________
Python-Dev mailing list
Python-Dev@python.org
http://mail.python.org/mailman/listinfo/python-dev
Unsubscribe: 
http://mail.python.org/mailman/options/python-dev/archive%40mail-archive.com

Reply via email to