Python can't divide??!?!

mark mark at diversiform.com
Thu Feb 5 12:51:06 EST 2004


Additionally, I believe there is a typo in the example, as 3.0 / 3
results in 1.0.

- Mark

-----Original Message-----
From: python-list-bounces+mark=diversiform.com at python.org
[mailto:python-list-bounces+mark=diversiform.com at python.org] On Behalf
Of Dan Williams
Sent: Thursday, February 05, 2004 9:45 AM
To: python-list at python.org
Subject: Python can't divide??!?!
Importance: High

Ummmm...

This is weird. Sorry if it's known about (how can it NOT be, I wonder?)
but
I haven't seen any reference to it anywhere.

I'm running the latest Python (2.3.3) on Windows XP Pro, i386
architecture.

Fire up python or whatever.

Do this:     Result:

3 / 5        0                       Fair enough, int / int = int
3 / 5.0      0.59999999999999998     eh?
3.0 / 3      0.59999999999999998     ummmm...
3.0 / 5.0    0.59999999999999998     how did I guess...

That's just an example. Python cannot divide. Period. If you try 1.0 / 3
you
get 0.33333333333333331, and from this, the above example, and a few
tests,
I speculate that *something* is subtracting 2 from the last digit
*after*
the division is done.

Wacky.

Now, is this just me, or can someone else duplicate it? I've tried it on
two
computers here, but they're both Win XP. I'm about to test it on Linux
but I
figured I'd write this first.

Dan



-- 
http://mail.python.org/mailman/listinfo/python-list






More information about the Python-list mailing list