Using fractions instead of floats
horpner at yahoo.com
Tue Oct 2 13:42:09 CEST 2007
On 2007-10-01, Arnaud Delobelle <arnodel at googlemail.com> wrote:
> On Oct 1, 6:26 pm, Neil Cerutti <horp... at yahoo.com> wrote:
>> On 2007-10-01, Arnaud Delobelle <arno... at googlemail.com> wrote:
>> > Finally, arithmetic would become very confusing if there were
>> > three distinct numeric types; it already causes enough
>> > confusion with two!
>> Scheme says: It's not that bad.
> Scheme has prefix numeric operators, so that 1/2 is
> unambiguously (for the interpreter and the user) a litteral for
> 'the fraction 1/2'. You can't avoid the confusion in python, as
> binary operators are infix. Of course, we could create a new
> kind of litteral. Let's see, / and // are already operators,
> so why not use /// ? ;)
But you wouldn't actually need a literal rational represention.
But I'm just playing Devil's Advocate here; I like rationals in
Scheme and Lisp, but I don't see a need for them in Python.
On the other hand, Python has had complex numbers a long time,
and it doesn't need those more than rationals, does it? My guess
is that it got complex numbers but not rationals because
rationals just aren't very efficient.
But as a programmer, I'm mostly just a data-twiddler, and don't
generally need either of those numeric type in my day-to-day
work. So I'm not the guy to ask. ;)
I'm tired of hearing about money, money, money, money, money. I just want to
play the game, drink Pepsi, wear Reebok. --Shaquille O'Neal
More information about the Python-list