[MATRIX-SIG] integer division -- what a concept!
Fri, 16 Jan 1998 20:05:44 +0100 (MET)
Q: What is n/(n+1)?
This is of course wrong for most practical purposes,
but it is the result Python will give.
I'm aware that I should have written n/(n+1.0), or
typcast, or been more careful in the first place,
and that there are historical reasons;
nevertheless I think the above behaviour is
most unfortunate for the following reasons:
* Bugs can creep into the code in no time.
Just leave out a .0 ... And the
chance is not bad, especially when copying
algorithms from textbooks.
* These errors are extremely hard to find, because
calculations will yield valid, albeit wrong, values.
And how can you ever be sure you have found all of them?
* Explicit typecasts and .0's all over the place make
algorithms hard to read and comparison with textbooks
So, is there any way to change this behaviour?
MATRIX-SIG - SIG on Matrix Math for Python
send messages to: email@example.com
administrivia to: firstname.lastname@example.org