I wonder if I don't get something here... Why does qdiv(8,2)
return an mpq
instead of an mpz
?
See here:
Python 3.5.2 (default, Nov 23 2017, 16:37:01)
[GCC 5.4.0 20160609] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> from gmpy2 import qdiv
>>> help(qdiv)
Help on built-in function qdiv in module gmpy2:
qdiv(...)
qdiv(x[, y=1]) -> number
Return x/y as 'mpz' if possible, or as 'mpq' if x is not exactly
divisible by y.
>>> qdiv(8,2)
mpq(4,1)
>>> qdiv(4,1)
mpz(4)
I thought the whole idea was to return an mpz
if possible?
I believe that is a bug that was fixed in version 2.0.5. Your example works with 2.0.8. What version of gmpy2 are you using?
Edit
This is a bug in gmpy2 2.1.0 alpha release. A fix has been committed to the master trunk at the main repository - gmpy2. It will be included in version 2.1.0a5.