[Numpy-discussion] Re: numpy, overflow, inf, ieee, and rich comparison

Fredrik Lundh effbot at telia.com
Tue Oct 24 15:50:40 EDT 2000


Rainer Deyke wrote:
> "Alex Martelli" <aleaxit at yahoo.com> wrote:
> > Usability studies show that people without previous
> > experiences to bias them find 2/3=0.6666667 more
> > natural (that's the tidbit, emerged during the studies
> > for CP4E, which swayed our BDFL, I think).
>
> Everybody who expected 0.6666667, raise your hands.  Put your hands down.
> Now, everybody who expected 0.6667 raise your hands.  How about those who
> expected 0.66666666666666663 (the "real" result of 2.0/3.0 on my computer)?
> Anybody?

the usability studies alex was referring to were
done in the alice project (www.alice.org).

Alice uses python to control 3D objects, and they
found that users had real problems accepting that

    myBunny.moveForward(2/3)

left the bunny standing there, instead of moving it
2/3 units forward.

but for programmers, the real problem is that "/" in an
expression like "a/2" is sometimes an integer division,
and sometimes a floating point division, depending on
what data you happen to pass your function...

I've been programming Python full time for over five
years, and this is still causing me headaches from time
to time (I never had this problem when I was using C
and C++.  go figure ;-)

> In all of those cases, the result was truncated or rounded.  2/3=0 is just
> more obvious and predictable about it.

I doubt "obvious" is the right word here...

</F>





More information about the Python-list mailing list