14 Integers

One of the most fundamental datatypes in every programming language is the integer type. GAP is no exception.

GAP integers are entered as a sequence of decimal digits optionally preceded by a '+' sign for positive integers or a '-' sign for negative integers. The size of integers in GAP is only limited by the amount of available memory, so you can compute with integers having thousands of digits.

gap> -1234;
-1234
gap> 123456789012345678901234567890123456789012345678901234567890;
123456789012345678901234567890123456789012345678901234567890 

Many more functions that are mainly related to the prime residue group of integers modulo an integer are described in chapter Number Theory, and functions dealing with combinatorics can be found in chapter Combinatorics.

  • Integers V
  • PositiveIntegers V
  • NonnegativeIntegers V

    These global variables represent the ring of integers and the semirings of positive and nonnegative integers, respectively.

    gap> Size( Integers ); 2 in Integers;
    infinity
    true
    

  • IsIntegers( obj ) C
  • IsPositiveIntegers( obj ) C
  • IsNonnegativeIntegers( obj ) C

    are the defining categories for the domains Integers, PositiveIntegers, and NonnegativeIntegers.

    gap> IsIntegers( Integers );  IsIntegers( Rationals );  IsIntegers( 7 );
    true
    false
    false
    

    Integers is a subset of Rationals, which is a subset of Cyclotomics. See Chapter Cyclotomic Numbers for arithmetic operations and comparison of integers.

    Sections

    1. Elementary Operations for Integers
    2. Quotients and Remainders
    3. Prime Integers and Factorization
    4. Residue Class Rings

    [Top] [Previous] [Up] [Next] [Index]

    GAP 4 manual
    February 2000