Martin Manns wrote: > Hi, > > I am starting to use rationals and since I found no batteries included, > I tried out the mxNumber package. > > However, I get strange warnings on comparison operations > (which however seem to yield correct results): > > --- > $ python > Python 2.4.3 (#1, Jan 15 2007, 15:46:19) > [GCC 4.1.1 (Gentoo 4.1.1-r3)] on linux2 > Type "help", "copyright", "credits" or "license" for more information. >>>> from mx.Number import * >>>> a=Rational(0,1) >>>> a > 0/1 >>>> str(a) > '0.0' >>>> b=-5000000000000000000000000000000000000000000000000000000000 >>>> b > -5000000000000000000000000000000000000000000000000000000000L >>>> a==b > __main__:1: RuntimeWarning: tp_compare didn't return -1, 0 or 1 > False > --- > > How do I get rid of these warnings? > > Is there any rational number library around that > 1) is comparably fast for large denominators > 2) allows deriving types from Rationals without wrapping? > > Regards > > Martin > > P.S. The respective mailing list does not like me, so that I try my > luck here.
I quick search of Google turned up: http://books.google.com/books?id=1Shx_VXS6ioC&pg=PA625&lpg=PA625&dq=python+rational+number+library&source=web&ots=BA8_4EXdQ4&sig=aDEnYA99ssKe7PSweVNyi8cS2eg http://calcrpnpy.sourceforge.net/clnum.html http://gmpy.sourceforge.net/ -Larry -- http://mail.python.org/mailman/listinfo/python-list