|  |  6.4 Miscellaneous oddities 
 
integer division
If two numerical constants (i.e., two sequences of digits) are divided
using the /operator, the surrounding whitespace determines
which division to use: if there is no space between the constants and
the/operator (e.g., "3/2"), both numerical constants are
treated as of typenumberand the current ring division is
used. If there is at least one space surrounding the/operator
(e.g., "3 / 2"), both numerical constants are treated as of typeintand an integer division is performed. To avoid confusion, use
thedivoperator instead of/for integer division and an
explicit type cast tonumberfor ring division. Note, that this
problem does only occur for divisions of numerical constants.
It also applies for large numerical constants which are of typebigint. |  |   ring r=32002,x,dp;
==> // ** 32002 is invalid as characteristic of the ground field. 32003 is us\
   ed.
  3/2;    // ring division
==> -16000
  3 / 2;  // integer division
==> // ** int division with `/`: use `div` instead in line >>  3 / 2;  // int\
   eger division<<
==> 1
  3 div 2;
==> 1
  number(3) / number(2);
==> -16000
  number a=3;
  number b=2;
  a/b;
==> -16000
  int c=3;
  int d=2;
  c / d;
==> // ** int division with `/`: use `div` instead in line >>  c / d;<<
==> 1
 | 
 
monomials and precedence
The formation of a monomial has precedence over all operators
(a monomial is here an optional coefficient followed by any sequence
of ring variables (possibly followed by
an exponent) which only conssist of letters, digits
and (over the rationals) /without any whitespace): During that formation no operator is involved: in the non-commutative
case, we have|  |   ring r=0,(x,y),dp;
  2xy^2 == (2*x*y)^2;
==> 1
  2xy^2 == 2x*y^2;
==> 0
  2x*y^2 == 2*x * (y^2);
==> 1
 | 
 |  |   LIB "nctools.lib";
  ring r = 0,(x,y),dp;
  def S = superCommutative();
  xy == yx;
==> 1
  x*y == y*x;
==> 1
  x*y, y*x;
==> xy xy
 | 
 
meaning of mult
For an arbitrary ideal or module i,mult(i)returns the
multiplicity of the ideal generated by the leading monomials of the
given generators ofi, hence depends on the monomial ordering! 
A standard mistake is to interpret degree(i)ormult(i)for an inhomogeneous idealias the degree of the homogenization
or as something like the 'degree of the affine part'. For the orderingdp(degree reverse lexicographical) the converse is true: ifiis given by a standard basis,mult(i)is the degree of
the homogeneous ideal obtained by homogenization ofiand then
putting the homogenizing variable to 0, hence it is the degree of the
part at infinity (this can also be checked by looking at the initial
ideal). 
size of ideals
sizecounts the non-zero entries of an ideal or module. Usencolsto determine the actual number of entries in the ideal or module. 
computations in qring
In order to speed up computations in quotient rings, SINGULAR
usually does not reduce polynomials w.r.t. the quotient ideal; rather
the given representative is used as long as possible during
computations. If it is necessary, reduction is done during standard base
computations. To reduce a polynomial fby hand w.r.t. the
current quotient ideal use the commandreduce(f,std(0))(see  reduce). 
degree of a polynomial
 
degBoundThe exact meaning of "degree" depends on the ring odering and the command:
 slimgbuses always the total degree with weights 1,stddoes so only for block orderings.hilbthe degree is the total degree with weights 1 unless a weight vector is given
kbasethe degree is the total degree with weights 1
(to use another weight vector see  weightKB)
 
substring selection
To extract substrings from a string, square brackets are used,
enclosing either two comma-separatedints or anintvec. Although two comma-separatedints represent anintvec, they mean different things in substring access. Square
brackets enclosing twoints (e.g.s[2,6]) return a
substring where the first integer denotes the starting position and the
second integer denotes the length of the substring. The result is
returned as astring. Square brackets enclosing anintvec(e.g.s[intvec(2,6)]) return the characters of the string at the
position given by the values of theintvec. The result is
returned as an expression list of strings. 
 |  |   string s = "one-word";
  s[2,6];     // a substring starting at the second char
==> ne-wor
  size(_);
==> 6
  intvec v = 2,6;
  s[v];      // the second and the sixth char
==> n o
  string st = s[v];  // stick together by an assignment
  st;
==> no
  size(_);
==> 2
  v = 2,6,8;
  s[v];
==> n o d
 | 
 
packages and indexed variables
See example
 |  | package K;
string varok; exportto(K,varok);
string work(1); exportto(K,work(1));
int i(1..3); exportto(K,i(1..3));
// Toplevel does not contain i(1..3)
listvar();
// i(1..3) are stored in Package 'K'
listvar(K);
==> // K                              [0]  package K (N)
==> // ::i(3)                         [0]  int 0
==> // ::i(2)                         [0]  int 0
==> // ::i(1)                         [0]  int 0
==> // ::work(1)                      [0]  string 
==> // ::varok                        [0]  string 
 | 
 
 
 |