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

Konrad Hinsen hinsen@ibs.ibs.fr
Wed, 21 Jan 1998 10:36:39 +0100

> And it confused me too, though I am hardly a newbie, b/c I didn't
> actually know that my two and my three, were integers.  I have
> littered my code now with float(x) and float(y), to promote my input
> variables to the right type, but I have to say, this is hideously
> ugly.

It also creates another problem: your code won't work with complex
numbers any more, because float() applied to a complex number raises
an exception. If you want code to work for *all* numeric types, the
most general "number conversion" is x = x + 0. (or, if you want some
variation, x = 1.*x).
Konrad Hinsen                          | E-Mail: hinsen@ibs.ibs.fr
Laboratoire de Dynamique Moleculaire   | Tel.: +33-
Institut de Biologie Structurale       | Fax:  +33-
41, av. des Martyrs                    | Deutsch/Esperanto/English/
38027 Grenoble Cedex 1, France         | Nederlands/Francais

MATRIX-SIG  - SIG on Matrix Math for Python

send messages to: matrix-sig@python.org
administrivia to: matrix-sig-request@python.org