Singular Manual: int expressions

| ### 4.7.2 int expressions An int expression is: a sequence of digits (if the number represented by this sequence is too large to fit into the range of integers it is automatically converted to the type number, if a basering is defined) an identifier of type int a function returning int an expression involving ints and the arithmetic operations `+`, `-`, `*`, `div` (`/`), `%` (`mod`), or `^` a boolean expression a type cast to int Note: Variables of type int represent the compiler integers and are, therefore, limited in their range (see Limitations). If this range is too small the expression must be converted to the type number over a ring with characteristic 0. Example:
    12345678901; // too large
    ==> 12345678901
    typeof(_);
    ==> bigint
    ring r=0,x,dp;
    12345678901;
    ==> 12345678901
    typeof(_);
    ==> bigint
    // Note: 11*13*17*100*200*2000*503*1111*222222
    // returns a machine integer:
    11*13*17*100*200*2000*503*1111*222222;
    ==> // ** int overflow(*), result may be wrong
    ==> -6869239595516308480
    // using the type cast number for a greater allowed range
    number(11)*13*17*100*200*2000*503*1111*222222;
    ==> 12075748128684240000000
    ring rp=32003,x,dp;
    12345678901;
    ==> 12345678901
    typeof(_);
    ==> bigint
    intmat m[2][2] = 1,2,3,4;
    m;
    ==> 1,2,
    ==> 3,4
    m[2,2];
    ==> 4
    typeof(_);
    ==> int
    det(m);
    ==> -2
    m[1,1] + m[2,1] == trace(m);
    ==> 0
    ! 0;
    ==> 1
    1 and 2;
    ==> 1
    intvec v = 1,2,3;
    def d =transpose(v)*v;    // scalarproduct gives an 1x1 intvec
    typeof(d);
    ==> intvec
    int i = d[1];             // access the first (the only) entry in the intvec
    ring rr=31,(x,y,z),dp;
    poly f = 1;
    i = int(f);               // cast to int
    // Integers may be converted to constant  polynomials by an assignment,
    poly g=37;
    // define the constant polynomial g equal to the image of
    // the integer 37 in the actual coefficient field, here it equals 6
    g;
    ==> 6
See Type conversion and casting; number.

User manual for Singular version 4.4.1, 2025, generated by texi2html.