[PYTHON MATRIX-SIG] Something broken with __mul__?

Jim Hugunin hugunin@mit.edu
Fri, 18 Oct 1996 12:27:09 -0400


> Just to add *why* multiplication with * fails: it doesn't
> accept an integer and a Float32 as arguments. Making either
> or both arguments float solves the problem.
> 
> I don't remember exactly the result of the long debate about
> coercion and combination of different data types, but somehow
> I think this is not correct...

This was the best compromise I could come up with after all of the many
debates.  I don't think it's reasonable to have a long int multiplied by a
32-bit float return a 32-bit float (which is usually what I want when doing
this calculation).  As you say, it's not to hard to work around this
problem by making the integer a float, ie.

 print b*3.

I like this feature of having to think and add the decimal point because it
makes clear that the array you are going to get back will contain doubles
and not floats.

-Jim


=================
MATRIX-SIG  - SIG on Matrix Math for Python

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