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

Konrad Hinsen hinsen@ibs.ibs.fr
Mon, 19 Jan 1998 14:22:43 +0100

> Q: What is n/(n+1)?
> A: 0

Evidently everybody has had a lot of fun during the weekend discussing
this problem, so I can't resist joining in ;-)

What has happened on the Matrix SIG is a collision of two world views:

1) The various number representation are different data types, and
   should behave according to some generally accepted rules for
   type consistency. This is the view taken by C, Fortran, Python, etc.

2) There is just one data type "number", and the various representations
   are only implementation details that shouldn't influence the
   definition of mathematical operations or their outcome. This
   is the view taken by APL, Matlab, etc.

Having done both science and systems programming, I can sympathize
with both views. And Python could easily support both; it would be an
easy exercise to implement a new data type "number" that behaves like
most mathematicians and scientists would expect. Yet it wouldn't
solve the problems people have, because number constants would still
be of types "int" or "float", not of type "number".

My ideal language would treat all numbers as being of one type by
default, but provide special "integer" and "float" types whose
constants are marked by some prefix or postfix. The reason for
choosing the "number" approach as the default is that this corresponds
to what most newcomers to programming expect from their math classes.

Neverthless I hope that Python's approach will not change, for the
simple reason of compatibility. We'll have to live with the fact
that Python is not perfect - just better than other languages ;-)
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