How about adding rational fraction to Python?

Grant Edwards grante at visi.com
Thu Feb 28 18:26:04 EST 2008


On 2008-02-28, Steven D'Aprano <steve at REMOVE-THIS-cybersource.com.au> wrote:

> But that's not true. The consensus, across the majority of
> people (both programmers and non-programmers alike) is that
> 1/2 should return 0.5.  There's a small minority that argue
> for a rational result, and a bigger minority who argue for 0.

Yeay! I'm in the bigger minority!

> The interesting case is -1/2. According to the argument that
> "2 doesn't go into 1", -1/2 should also return 0. But that's
> not what Python returns, so it looks like the "int division"
> camp is screwed no matter whether Python keeps the status quo
> or the other status quo.

I do integer division pretty regularly, but apparently never on
negative numbers since I wasn't even aware that -1/2 yields -1
(yes, I'm still running 2.4).

-- 
Grant Edwards                   grante             Yow! Awright, which one of
                                  at               you hid my PENIS ENVY?
                               visi.com            



More information about the Python-list mailing list