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

Rainer Deyke root at rainerdeyke.com
Tue Oct 24 17:46:10 EDT 2000


"Fredrik Lundh" <effbot at telia.com> wrote in message
news:kKlJ5.2434$QH2.221699 at newsb.telia.net...
> Rainer Deyke wrote:
> > 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.

Ah, a rigged experiment.  This this special case, I agree that truncation
seems unnatural, because movement is continuous.

Did the experiment also show that people expect three calls to
myBunny.moveForward(2/3) to be subtly different from one call to
myBunny.moveForward(2)?

> 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 find that this is usually obvious from the context.  If a floating point
argument makes sense (which is almost never the case in my experience),
convert to floating point before dividing.


--
Rainer Deyke (root at rainerdeyke.com)
Shareware computer games           -           http://rainerdeyke.com
"In ihren Reihen zu stehen heisst unter Feinden zu kaempfen" - Abigor





More information about the Python-list mailing list