3.1 The Integers

The class IntegerRing represents the ring $\mathbf{Z}$ of (arbitrary precision) integers. Each integer is an instance of the class Integer, which is defined in a Pyrex extension module that wraps GMP integers (the mpz_t type in GMP).

The class IntegerRing represents the ring $\mathbf{Z}$ of integers. This class is available by default from the SAGE interpreter.

>>> Z = IntegerRing(); Z
Integer Ring
>>> Z.characteristic()
0
>>> Z.is_field()
False
All instances of class IntegerRing are the same. To create an Integer, coerce either a Python integer, or a string.
>>> a = Z(1234); b = Z(5678); print a, b
1234 5678
>>> type(a)
<type 'integer.Integer'>
>>> a + b
6912
>>> Z('94803849083985934859834583945394')
94803849083985934859834583945394



Subsections
See About this document... for information on suggesting changes.