gmpy floating point exception

Martin Manns mmanns at
Thu Mar 29 05:56:28 CEST 2007


I am experiencing some trouble with gmpy v1.01.
Multiplying an mpq with inf results in a floating point exception that
exits python. Has this already been fixed in newer gmpy versions? 

~ $ python
Python 2.4.3 (#1, Mar 26 2007, 00:32:54) 
[GCC 4.1.1 (Gentoo 4.1.1-r3)] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> from gmpy import mpq as Rational
>>> a=Rational(2,3)
>>> b=1.0e99999
>>> b
>>> int(b)
Traceback (most recent call last):
  File "<stdin>", line 1, in ?
OverflowError: cannot convert float infinity to long
>>> a+b
Floating point exception
~ $

1) What is the best way to test for inf regardless of type?
2) Is there any inf type around with
a + inf == inf
inf > a (as long as a != inf)
that works with any other type?

Thanks in advance


More information about the Python-list mailing list