Lossless Number Conversion

Andreas Kostyrka andreas at kostyrka.org
Mon Aug 29 03:21:02 EDT 2005


Am Sonntag, den 28.08.2005, 21:36 +0000 schrieb Chris Spencer:
> Is there any library for Python that implements a kind of universal 
> number object. Something that, if you divide two integers, generates a 
> ratio instead of a float, or if you take the square root of a negative, 
> generates a complex number instead of raising an exception? Lisp has 
> something like this, and it makes number crunching much more convenient.

Yes and no. There isn't general solution. But for example you want to
allow complex number, just use cmath.

Andreas
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 196 bytes
Desc: Dies ist ein digital signierter Nachrichtenteil
URL: <http://mail.python.org/pipermail/python-list/attachments/20050829/bdefd78c/attachment.sig>


More information about the Python-list mailing list