## `Dom::Integer` -- the ring of integer numbers

#### Introduction

`Dom::Integer` is the ring of integer numbers represented by elements of the domain `DOM_INT`.

#### Creating Elements

`Dom::Integer(x)`

#### Parameters

`x` | - | an integer

#### Categories

`Cat::EuclideanDomain`

, `Cat::FactorialDomain`, `Cat::DifferentialRing`, `Cat::OrderedSet`

#### Related Domains

`Dom::Complex`, `Dom::Float`, `Dom::Numerical`, `Dom::Rational`, `Dom::Real`

#### Details

- `Dom::Integer` is the domain of integer numbers represented by expressions of type `DOM_INT`.
- Elements of `Dom::Integer` are usually not created explicitly. However, if one creates elements using the usual syntax, it is checked whether the input is an integer number. This means that `Dom::Integer` is a faēcade domain which creates elements of domain type `DOM_INT`.
- Viewed as a differential ring `Dom::Integer` is trivial, it contains constants only.
- `Dom::Integer` has the domain `Dom::Numerical` as its super domain, i.e., it inherits each method which is defined by `Dom::Numerical` and not re-implemented by `Dom::Integer`. Methods described below are those implemented by `Dom::Integer`.

#### Method associates: associate elements

- `associates(dom x, dom y)`
- - This method returns `TRUE` if `x` and `y` are associates, i.e., if ``abs(x)` = `abs(y)``, otherwise it returns `FALSE`.

#### Method _divide: division of two objects

- `_divide(dom x, dom y)`
- - This method returns `x/y` if `y` divides `x` and `FAIL` otherwise.

#### Method _divides: decide if a number divides another one

- `_divides(dom x, dom y)`
- - This method returns `TRUE` if `x` divides `y`

#### Method euclideanDegree: Euclidean degree

- `euclideanDegree(dom x)`
- - This method returns the Euclidean degree of `x`, i.e., `abs(x)`.

#### Method factor: factorization

- `factor(dom x)`
- - This method returns the factorization of `x`. The result of this method is an object of the domain `Factored`.

#### Method gcd: gcd computation

- `gcd(dom x1, dom x2...)`
- - This method returns the gcd of the given arguments `x1, x2...`

#### Method gcdex: applies the extended Euclidean algorithm

- `gcdex(dom x, dom y)`
- - This method returns g, v, w such that g = gcd(x,y) = x*v + y*w.

#### Method _invert: inverse of an element

- `_invert(dom x)`
- - This method returns the multiplicative inverse of `x`. This is `x` if `x` is `1` or `-1`, and `FAIL` otherwise.

#### Method irreducible: prime number test

- `irreducible(dom x)`
- - This method returns `TRUE` if and only if `x` is prime.

#### Method isUnit: tests if an element is a unit

- `isUnit(dom x)`
- - This method returns `TRUE` if `x` is a unit, i.e., if `x` is `1` or `-1`, otherwise it returns `FALSE`.

#### Method lcm: computes the lcm

- `lcm(dom x1, dom x2...)`
- - This method returns the lcm of the given arguments `x1, x2...`

#### Method quo: computes the euclidean quotient

- `quo(dom x, dom y)`
- - This method returns the euclidean quotient of `x` and `y`, i.e., `x` div y.

#### Method random: random number generation

- `random()`
- - This methods returns a random integer number between -999 and 999.
- `random(integer n)`
- - This methods returns a random number between 0 and `n`-1.
- `random(integer m..integer n)`
- - This methods returns a random number between `m` and `n`.

#### Method rem: computes the Euclidean reminder

- `rem(dom x, dom y)`
- - This method returns the Euclidean reminder of `x` and `y`, i.e., `modp(x,y)`.

#### Method unitNormal: unit normal part

- `unitNormal(dom x)`
- - This method returns the unit normal part of `x`, i.e., `abs(x)`.

#### Method unitNormalRep: unit normal representation

- `unitNormalRep(dom x)`
- - This method returns the unit normal representation of `x`, i.e., the list `[`abs(x), `sign`(x), -`sign`(x)].

#### Method convert: conversion of objects

- `convert(any x)`
- - This method tries to convert `x` to a integer of type `Dom::Integer`. This is only possible if `x` is of type `DOM_INT`. If the conversion fails, `FAIL` is returned.

#### Method convert_to: conversion to other domains

- `convert_to(dom x, any T)`
- - This method tries to convert the number `x` to an element of type `T`, or, if `T` is not a domain, to the domain type of `T`. If the conversion fails, then `FAIL` is returned.
  - The following domains are allowed for for `T`: `DOM_INT`, `Dom::Integer`, `Dom::Rational`, `DOM_FLOAT`, `Dom::Float` and `Dom::Numerical`.

#### Method testtype: type checking

- `testtype(any x, dom T)`
- - This method checks whether it can convert `x` to the domain `Dom::Integer`. This is the case if `x` is of type `DOM_INT`. It returns `TRUE` if it can perform the conversion. Otherwise `FAIL` is returned.
  - Usually, this method is called from the function `testtype` and not directly by the user. Example 2 demonstrates this behavior.

#### Example 1

Creating some integer numbers using `Dom::Integer`. This example also shows that `Dom::Integer` is a faēcade domain.

    >> Dom::Integer(2); domtype(%)

                                         2

                                      DOM_INT

    >> Dom::Integer(2/3)

          Error: illegal arguments [Dom::Integer::new]

#### Example 2

By tracing the method `Dom::Integer::testtype` we can see the interaction between `testtype` and `Dom::Integer::testtype`.

    >> prog::trace(Dom::Integer::testtype):
       delete x:
       testtype(x, Dom::Integer);
       testtype(3, Dom::Integer);
       prog::untrace(Dom::Integer::testtype):

          enter 'Dom::Integer::testtype'         with args   : x, Dom::Integer
          leave 'Dom::Integer::testtype'         with result : FAIL

                                       FALSE
          enter 'Dom::Integer::testtype'         with args   : 3, Dom::Integer
          leave 'Dom::Integer::testtype'         with result : TRUE

                                       TRUE

#### Super-Domain

`Dom::Numerical`

#### Axioms

`Ax::canonicalRep`

, `Ax::systemRep`, `Ax::canonicalOrder`, `Ax::canonicalUnitNormal`, `Ax::closedUnitNormals`, `Ax::efficientOperation("_divide")`, `Ax::efficientOperation("_mult")`

#### Changes

- no changes

Do you have questions or comments?
Copyright © SciFace Software GmbH & Co. KG 2000