# [MATRIX-SIG] integer division -- what a concept!

**Carlos Maltzahn
**
carlosm@moet.cs.colorado.edu

*Fri, 16 Jan 1998 13:10:37 -0700 (MST)*

I disagree:
Assuming n is an integer matrix. If you expect float results from matrix
operations you should have the matrices typed as float in the first
place. This would ensure that all operations result in floats.
Also, I've come across plenty of situations where I want integer division
with integer results. In these cases I would pay a big performance penalty
if Python would do float operations with results that I would have to
convert back to integers.
Carlos
On Fri, 16 Jan 1998, Rupert Mazzucco wrote:
>* Q: What is n/(n+1)?
*>* A: 0
*>*
*>* 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
*>* difficult.
*>*
*>* So, is there any way to change this behaviour?
*>*
*>* Thank you,
*>* Rupert Mazzucco
*>*
*>* _______________
*>* MATRIX-SIG - SIG on Matrix Math for Python
*>*
*>* send messages to: matrix-sig@python.org
*>* administrivia to: matrix-sig-request@python.org
*>* _______________
*>*
*
_______________
MATRIX-SIG - SIG on Matrix Math for Python
send messages to: matrix-sig@python.org
administrivia to: matrix-sig-request@python.org
_______________