Package sage :: Package rings :: Module integer_ring :: Class IntegerRing
[show private | hide private]
[frames | no frames]

Type IntegerRing

      Ring --+
             |
object --+   |
         |   |
 _uniq_int --+
             |
            IntegerRing


The ring of integers.

EXAMPLES: We create the rational numbers and call a few functions:
>>> Z = IntegerRing(); Z
Integer Ring

>>> Z.characteristic()
0

>>> Z.is_field()
False
We illustrate arithmetic in Z.
>>> a = Z(1234); b = Z(5678); print a, b
1234 5678

>>> type(a)
<type '_integer.Integer'>

>>> a + b
6912

>>> b + a
6912

>>> a * b
7006652

>>> b * a
7006652

>>> a - b
-4444

>>> b - a
4444
When we divide, the result is automatically coerced to the rationals, even if the result is an integer.
>>> a / b
617/2839

>>> type(a/b)
<type '_rational.Rational'>

>>> a/a
1

>>> type(a/a)
<type '_rational.Rational'>
Next we illustrate arithmetic with automatic coercion. The types that coerce are: str, int, long, Integer.
>>> a + 17
1251

>>> a * 374
461516

>>> 374 * a
461516

>>> a/19
1234/19

>>> 0 + Z(-64)
-64
Integers can be coerced:
>>> a = Z(-64)
>>> int(a)
-64

>>> long(a)
-64L

Method Summary
  __call__(self, x)
Coerce x into the ring.
  __cmp__(self, other)
  __contains__(self, x)
  __repr__(self)
  characteristic(self)
Return 0 as a Python int.
  is_atomic_repr(self)
Return True, since elements of the integers do not have to be printed with paranethesis around them, when they are coefficients, e.g., in a polynomial.
  is_field(self)
Return False.
  name(self)
Return the string "Z".
  random(self, bound)
Return a random integer between -bound and bound, including both endpoints.
  zeta(self)
Return the integer -1, which is the root of unity of largest order in Z.
    Inherited from object
  __init__(...)
x.__init__(...) initializes x; see x.__class__.__doc__ for signature
  __delattr__(...)
x.__delattr__('name') <==> del x.name
  __getattribute__(...)
x.__getattribute__('name') <==> x.name
  __hash__(x)
x.__hash__() <==> hash(x)
  __reduce__(...)
helper for pickle
  __reduce_ex__(...)
helper for pickle
  __setattr__(...)
x.__setattr__('name', value) <==> x.name = value
  __str__(x)
x.__str__() <==> str(x)
    Inherited from Ring
  type(self)

Instance Method Details

__call__(self, x)
(Call operator)

Coerce x into the ring.
Overrides:
sage.rings.ring.Ring.__call__ (inherited documentation)

characteristic(self)

Return 0 as a Python int.
Overrides:
sage.rings.ring.Ring.characteristic

is_atomic_repr(self)

Return True, since elements of the integers do not have to be printed with paranethesis around them, when they are coefficients, e.g., in a polynomial.
Overrides:
sage.rings.ring.Ring.is_atomic_repr

is_field(self)

Return False.
Overrides:
sage.rings.ring.Ring.is_field

name(self)

Return the string "Z".
Overrides:
sage.rings.ring.Ring.name

random(self, bound=5)

Return a random integer between -bound and bound, including both endpoints.

zeta(self)

Return the integer -1, which is the root of unity of largest order in Z.

Generated by Epydoc 2.1 on Mon Jun 20 15:43:21 2005 http://epydoc.sf.net