How about adding rational fraction to Python?

Grant Edwards grante at visi.com
Tue Feb 26 16:34:39 EST 2008


On 2008-02-26, Torsten Bronger <bronger at physik.rwth-aachen.de> wrote:
> Hallöchen!
>
> Grant Edwards writes:
>
>> [...]
>>
>> Nope.  I would prefer that int OP int always produce an int.
>
> And 2**-1?

An error.

> Your formulation tries to suggest some sort of logical
> consequence but in my opinion, it's still a mere matter of
> taste and habits.  I remember my first steps in C++ 12 years
> ago when I tried to implement a couple of astronomical
> formulae, always getting false results because C++ calculated
> 3/4=0.
>
> I think the only real reason for people prefering int/int=int
> is that computers can deal with inteters better than with
> floats, resulting in int-only arithmetic in computer
> languages.  However, I don't consider this a particularly good
> reason.

Well, another reason is that there is existing code that
depends on int/int => int.

-- 
Grant Edwards                   grante             Yow! What a COINCIDENCE!
                                  at               I'm an authorized "SNOOTS
                               visi.com            OF THE STARS" dealer!!



More information about the Python-list mailing list