[MATRIX-SIG] Re: int. division

David J. C. Beach beach@verinet.com
Sat, 17 Jan 1998 11:12:10 -0700

Rupert Mazzucco wrote:

>   I[n] = float1 + ( n / ( n+1 )) * float2
> Maybe this could be evaluated differently, so that the interpreter
> sees we're really talking about floats here and does the correct
> conversion for n/(n+1) *before* dividing? (because I is typed float,
> that is, not primarily because of float1 or float2)

This isn't generally a good, though.  Asignment in python can change (or define)
the type of a scalar variable.

If  x is a free variable (has not yet beed used),

x = 3/4

is entirely unclear.  x doesn't have a type yet, so I don't know whether to do
0.75 == 3.0/4.0 or 0 == 3/4

In any case, I'm going to stop arguing here.  If you feel very strongly about
3/4==0.75, you can talk to Guido about it and see if he'll change it.  My guess
is that he will tell you, "sorry, 'fraid not" because Guido is reasonably
committed to keeping existing python programs compatible with new python
features.  Such a change would break a tremendous amount of existing code.


David J. C. Beach
Colorado State University

MATRIX-SIG  - SIG on Matrix Math for Python

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