gmpy floating point exception

Martin Manns mmanns at gmx.net
Wed Mar 28 23:56:28 EDT 2007


Hi,

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
inf
>>> int(b)
Traceback (most recent call last):
  File "<stdin>", line 1, in ?
OverflowError: cannot convert float infinity to long
>>> a+b
Floating point exception
~ $


BTW.
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)
etc.
that works with any other type?

Thanks in advance

Martin



More information about the Python-list mailing list