In article <[EMAIL PROTECTED]>,
Facundo Batista <[EMAIL PROTECTED]> writes:
|> Noud Aldenhoven wrote:
|> 
|> > When I was programming in a mathematical project I began to wonder if 
python
|> > supports rational numbers[1]. In a language like magma[2] it's not such a
|> > problem. Does python supports something simular?
|> 
|> Python does not have rational numbers.
|> 
|> There's a (rejected) PEP about this, PEP-239:
|> 
|>   http://www.python.org/dev/peps/pep-0239/
|> 
|> Maybe you also want to read the section "Why not rational?" of
|> PEP-327...
|> 
|>   http://www.python.org/dev/peps/pep-0327/#why-not-rational

Oh, God.  Decimal delusions again :-(

There are good arguments for not having a rational type, but the idea
that decimal floating-point is in any way a replacement is cuckoo.
The desirable properties that rationals and decimal arithmetic provide
are both genuine and are almost entirely different ....

There are also perfectly good representations that don't have the
performance implications mentioned:  fixed and floating slash arithmetic.
They are mathematically quite interesting, and have some desirable
properties not shared by any floating-point format: e.g. if the result
is theoretically a rational with small numerator and denominator, then
they are very likely to return it.  I implemented fixed slash once, and
it is very easy to do - all it needs is a GCD routine - like rational,
it would be straightforward to add to Python as an extension type.


Regards,
Nick Maclaren.
-- 
http://mail.python.org/mailman/listinfo/python-list

Reply via email to