[MATRIX-SIG] integer division etc.

Zane Motteler zcm@llnl.gov
Tue, 20 Jan 1998 08:16:48 -0800


There seems to be a lot of sentiment out there that a number
is a number, and that 1/2 really ought to be 0.5, a float.
And, to paraphrase, that in a high level language you shouldn't
have to worry about type.

Integer operations really are distinct from floating point,
and there really are important cases where one wants the integer
result. I have done extensive work with graphics in Python,
and part of this involves computations with arrays of integers
which are actually subscripts into arrays of data. I really
do want division (/) and mod (%) to be operations which give
integer results. No matter how much you may not want to worry
about type, you still can't use a float for a subscript in
Python.

To me, saying that 1/2 ought to be 0.5 makes about as much
sense as saying "1"+"2" ought to be 3 rather than "12".

Cheers

Zane


-----------------------------------------------------------------
                      Zane C. Motteler, Ph. D.
Computer Scientist             | Professor Emeritus of
Lawrence Livermore National    |    Computer Science and Engineering
   Laboratory                  | California Polytechnic
P. O. Box 808, L-472           |    State University
(7000 East Avenue, zip 94550)  | San Luis Obispo, CA 93407
Livermore, CA 94551-9900       | zmottel@phoenix.csc.calpoly.edu
510/423-2143, FAX 423-9969 (Area code 925 after March 14, 1998)
zcm@llnl.gov



_______________
MATRIX-SIG  - SIG on Matrix Math for Python

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