fuzzylogician / gmpy

Automatically exported from code.google.com/p/gmpy
GNU Lesser General Public License v3.0
0 stars 0 forks source link

Bug in gmpy2.qdiv ? #94

Closed GoogleCodeExporter closed 8 years ago

GoogleCodeExporter commented 8 years ago
This will show the problem (32-bit Python 3.4.2 with gmpy2 2.0.3):

import gmpy2
a=gmpy2.qdiv(1,2147483647)
a
a=gmpy2.qdiv(1,2147483648)
a
a

The first "a" shows mpq(1,2147483647) as expected.

The second "a" throws an exception:
    "OverflowError: Python int too large to convert to C long"

The last "a" shows mpq(1,2147483648) as expected.

The exception is the problem, and it's throwed not only when showing the 
contents of "a", but also in subsequent computations, like in:
a = gmpy2.qdiv(1, 2147483648)
b = a + 1

Original issue reported on code.google.com by arbau...@gmail.com on 10 Dec 2014 at 4:15

GoogleCodeExporter commented 8 years ago
[deleted comment]
GoogleCodeExporter commented 8 years ago
Also, it seems that any higher value of the denominator and any value of the 
numerator, will cause the same problem.

And the denominator 2147483648 = 2**31 is the smallest that will cause this 
problem.

Original comment by arbau...@gmail.com on 10 Dec 2014 at 4:20

GoogleCodeExporter commented 8 years ago
Thanks for the bug report. I have found the cause and will be committing a fix 
soon. It will be a few days before I can make a new release. Here is a 
work-around:

gmpy2.qdiv(1,gmpy2.mpz(2147483648))

casevh

Original comment by casevh on 11 Dec 2014 at 5:27

GoogleCodeExporter commented 8 years ago
Thank you, and congratulations for the fast answer ! :-)

Jean-Claude Arbaut

2014-12-11 6:27 GMT+01:00 <gmpy@googlecode.com>:

Original comment by arbau...@gmail.com on 13 Dec 2014 at 12:15

GoogleCodeExporter commented 8 years ago
I have released version 2.0.5 which includes the fix.

I'm sorry it has taken so long to release the new version.

Case

Original comment by casevh on 13 Jan 2015 at 5:47

GoogleCodeExporter commented 8 years ago
No problem :-) Thank you, and once again, congratulations to the gmpy team
for all this work.

Jean-Claude Arbaut

2015-01-13 6:48 GMT+01:00 <gmpy@googlecode.com>:

Original comment by arbau...@gmail.com on 13 Jan 2015 at 8:00