Test divmod
============

>>> import gmpy2
>>> from gmpy2 import mpz, xmpz, mpq, mpfr, mpc
>>> from decimal import Decimal as D
>>> from fractions import Fraction as F
>>> a = mpz(123)
>>> b = mpz(456)
>>> c = 12345678901234567890

Test integer operations
-----------------------

>>> divmod(mpz(123),'a')
Traceback (most recent call last):
  ...
TypeError:
>>> divmod(mpq(1,2),'a')
Traceback (most recent call last):
  ...
TypeError:
>>> divmod(mpfr(1),'a')
Traceback (most recent call last):
  ...
TypeError:
>>> divmod(mpc(1),'a')
Traceback (most recent call last):
  ...
TypeError:
>>> ctx=gmpy2.context()
>>> ctx.divmod('a',456)
Traceback (most recent call last):
  ...
TypeError:
>>> ctx.divmod(a,mpc(456))
Traceback (most recent call last):
  ...
TypeError:
>>> ctx.divmod(mpc(1,2),mpc(3,4))
Traceback (most recent call last):
  ...
TypeError:
>>> ctx.divmod(mpfr(2),mpfr(1))
(mpfr('2.0'), mpfr('0.0'))
>>> ctx.divmod(mpq(3,2),mpq(3,7))
(mpz(3), mpq(3,14))
>>> ctx.divmod(1,2,3)
Traceback (most recent call last):
  ...
TypeError:
>>> ctx.divmod(456, 0)
Traceback (most recent call last):
  ...
ZeroDivisionError:
>>> ctx.divmod(a,b)
(mpz(0), mpz(123))
>>> ctx.divmod(123,456)
(mpz(0), mpz(123))
>>> divmod(mpz(1), mpc(1,2))
Traceback (most recent call last):
  ...
TypeError:
>>> divmod(mpq(1,2), mpc(1,2))
Traceback (most recent call last):
  ...
TypeError:
>>> divmod(mpfr(1), mpc(1,2))
Traceback (most recent call last):
  ...
TypeError:
>>> divmod(mpc(1,2), mpc(1,2))
Traceback (most recent call last):
  ...
TypeError:
>>> divmod(mpfr(1.2), mpfr(0.7))
(mpfr('1.0'), mpfr('0.5'))


>>> ctx=gmpy2.ieee(64)
>>> gmpy2.set_context(ctx)
>>> divmod(mpz(123),'a')
Traceback (most recent call last):
  ...
TypeError:
>>> divmod(mpq(1,2),'a')
Traceback (most recent call last):
  ...
TypeError:
>>> divmod(mpfr(1),'a')
Traceback (most recent call last):
  ...
TypeError:
>>> divmod(mpc(1),'a')
Traceback (most recent call last):
  ...
TypeError:
>>> ctx=gmpy2.context()
>>> ctx.divmod('a',456)
Traceback (most recent call last):
  ...
TypeError:
>>> ctx.divmod(a,mpc(456))
Traceback (most recent call last):
  ...
TypeError:
>>> ctx.divmod(mpc(1,2),mpc(3,4))
Traceback (most recent call last):
  ...
TypeError:
>>> ctx.divmod(456, 0)
Traceback (most recent call last):
  ...
ZeroDivisionError:
>>> divmod(mpfr(1.2), mpfr(0.7))
(mpfr('1.0'), mpfr('0.5'))
>>> ctx.clear_flags()
>>> ctx.divzero
False
>>> divmod(mpfr(1.2), mpfr(0))
(mpfr('nan'), mpfr('nan'))
>>>
>>> gmpy2.set_context(gmpy2.context())

