Rational numbers

M.-A. Lemburg mal at egenix.com
Fri Apr 27 19:35:47 CEST 2007


On 2007-02-23 16:35, 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?

FYI: The next version of mxNumber will have this warning removed.

> 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.

Why is that ? The egenix-user mailing is open for all our users.
We do require registration to stop spam from reaching the list.

-- 
Marc-Andre Lemburg
eGenix.com

Professional Python Services directly from the Source  (#1, Apr 27 2007)
>>> Python/Zope Consulting and Support ...        http://www.egenix.com/
>>> mxODBC.Zope.Database.Adapter ...             http://zope.egenix.com/
>>> mxODBC, mxDateTime, mxTextTools ...        http://python.egenix.com/
________________________________________________________________________

:::: Try mxODBC.Zope.DA for Windows,Linux,Solaris,MacOSX for free ! ::::


   eGenix.com Software, Skills and Services GmbH  Pastor-Loeh-Str.48
    D-40764 Langenfeld, Germany. CEO Dipl.-Math. Marc-Andre Lemburg
           Registered at Amtsgericht Duesseldorf: HRB 46611



More information about the Python-list mailing list