How about adding rational fraction to Python?

Grant Edwards grante at visi.com
Tue Feb 26 14:32:14 EST 2008


On 2008-02-26, J. Cliff Dyer <jcd at sdf.lonestar.org> wrote:

> So do you believe that you should not be able to do natural
> division without explicitly casting ints as floats,

IMO, you're begging the question by using the phrase "natural
division" when what you mean is "floating point division", but
yes, I prefer requiring explicit conversion to floating point.

> or is yourw concern just that you want to still be able to to
> integer division simply?

Nope.  I would prefer that  int OP int always produce an int.

> For me personally, I'm happy knowing that integer division is
> still available through the // operator.  I'm not offended
> that other, highly useful forms of division would be given
> operator status.  Granted, I'm not old school like you, but I
> do appreciate clean design, and typing:
>
> float(3)/4 always struck me as an ugly hack to get integers to do
> something that comes naturally to them--divide into a result outside the
> set of integral numbers.

Again, you're begging the question by using the term "natural"
to describe your opinion. I find int OP int => float to be
unnatural.  It's much too "implicit" for me.

> I agree that integer division is useful and important, but I
> don't think it's a travesty to support other kinds of
> division, especially when integer division still has its own
> operator.

If integer division is going to have it's own operator, why not
the same for integer subtraction or integer multiplication?
Yes, I know the theoretical answer, but from a computer
architecture POV, integer addition and floating point addition
are completely separate and unrelated things.

-- 
Grant Edwards                   grante             Yow! Well, O.K.
                                  at               I'll compromise with my
                               visi.com            principles because of
                                                   EXISTENTIAL DESPAIR!



More information about the Python-list mailing list