Rational Numbers

Noud Aldenhoven jwaixs at gmail.com
Thu Jan 11 23:20:14 CET 2007


On 1/11/07, Facundo Batista <facundo at taniquetil.com.ar> wrote:
>
> Python does not have rational numbers.


Ah, oke. Thank you, it seems I have enough information why they aren't
included in the core.

Question: Why do you say that it's a problem?


Well... Perhaps I word it wrong. It's not really a problem and if I need
rational numbers I'm smart enough to make an other algorithm that doesn't
need a build-in function for rational numbers.

I'm a mathematician (in learning, with a bad feeling for English) and don't
trust irrational numbers in programming languages.
It's, for example, in some cases it could be more efficient to compute an
irrational number with a rational numbers then using an advanced algorithm
of Euclides to compute the same.

To give a small example:

pi ~ 355/113
pi ~ 3.1415926

In my opinion the first one is better. But now I realise it's also the
slowest of the two implemented in python.

There are a (small) couple of other issues where rational numbers could be
handy. That's because rational numbers are exact, irrational numbers (in
python) aren't. But these issues are probably too mathematical to be used in
a programming language like python.

Regards,

Noud Aldenhoven

-- 
<:3 )~
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/python-list/attachments/20070111/25e3b963/attachment.html>


More information about the Python-list mailing list