MPZ Functionality
=================

Test the creation of mpz objects.

>>> from gmpy2 import mpz, mpq, mpfr, mpc, xmpz
>>> from decimal import Decimal as D
>>> from fractions import Fraction as F
>>> import gmpy2 as G

>>> mpz()
mpz(0)
>>> mpz(0)
mpz(0)
>>> mpz(1)
mpz(1)
>>> mpz(-1)
mpz(-1)
>>> mpz(2**15-2)
mpz(32766)
>>> mpz(2**15-1)
mpz(32767)
>>> mpz(2**15)
mpz(32768)
>>> mpz(2**15+1)
mpz(32769)
>>> mpz(2**15+2)
mpz(32770)
>>> mpz(2**30-2)
mpz(1073741822)
>>> mpz(2**30-1)
mpz(1073741823)
>>> mpz(2**30)
mpz(1073741824)
>>> mpz(2**30+1)
mpz(1073741825)
>>> mpz(2**30+2)
mpz(1073741826)
>>> mpz(2**16-2)
mpz(65534)
>>> mpz(2**16-1)
mpz(65535)
>>> mpz(2**16)
mpz(65536)
>>> mpz(2**16+1)
mpz(65537)
>>> mpz(2**16+2)
mpz(65538)
>>> mpz(1000000000000)
mpz(1000000000000)
>>> mpz(-1000000000000)
mpz(-1000000000000)
>>> mpz('')
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
ValueError: invalid digits
>>> mpz('a')
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
ValueError: invalid digits
>>> mpz('a',16)
mpz(10)
>>> mpz('z',16)
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
ValueError: invalid digits
>>> mpz('0b1101')
mpz(13)
>>> mpz('0b1101',2)
mpz(13)
>>> mpz('1101',2)
mpz(13)
>>> mpz('0b0010')
mpz(2)
>>> mpz('0b0010',2)
mpz(2)
>>> mpz('0b0b10',2)
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
ValueError: invalid digits
>>> mpz('0b0b10')
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
ValueError: invalid digits
>>> mpz('0b0012')
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
ValueError: invalid digits
>>> mpz('0o0012')
mpz(10)
>>> mpz('0o0012',8)
mpz(10)
>>> mpz('12',8)
mpz(10)
>>> mpz('0x12')
mpz(18)
>>> mpz('0x12',16)
mpz(18)
>>> mpz('12',16)
mpz(18)
>>> mpz('-1')
mpz(-1)
>>> mpz('+1')
mpz(1)
>>> mpz('  0xA', base=0)
mpz(10)
>>> mpz(float('nan'))
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
ValueError: 'mpz' does not support NaN
>>> mpz(float('inf'))
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
OverflowError: 'mpz' does not support Infinity
>>> mpz(float('-inf'))
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
OverflowError: 'mpz' does not support Infinity
>>> mpz(12, base=16)
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
TypeError: mpz() with non-string argument needs exactly 1 argument
>>> mpz('12', base=16)
mpz(18)
>>> mpz('\xff')
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
ValueError: ** message detail varies **
>>> mpz('\x0cf')
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
ValueError: ** message detail varies **
>>> mpz('\0xff')
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
ValueError: ** message detail varies **
>>> mpz(b'12')
mpz(12)
>>> mpz(None)
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
TypeError: ** message detail varies **
>>> mpz(None,base=10)
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
TypeError: ** message detail varies **
>>> mpz('99',base=100)
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
ValueError: ** message detail varies **
>>> mpz('99',base='a')
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
TypeError: ** message detail varies **
>>> mpz('99',base=10)
mpz(99)
>>> mpz(xmpz(5))
mpz(5)
>>> mpz('ы')
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
ValueError: string contains non-ASCII characters
>>> mpz(bytes('ы', encoding='utf-8'))
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
ValueError: string contains non-ASCII characters
