Home Online Manual
Top
Back: number declarations
Forward: number operations
FastBack: module
FastForward: package
Up: number
Top: Singular Manual
Contents: Table of Contents
Index: Index
About: About this document

4.14.2 number expressions

A number expression is:

  1. a rational number (there are NO spaces allowed inside a rational number, see int expressions)
  2. a floating point number (if the coefficient field is real):
    <digits>.<digits>e<sign><digits>
  3. an identifier of type number
  4. a function returning number
  5. an int expression (see Type conversion and casting)
  6. number expressions combined by the arithmetic operations +, -, *, /, ^, or **.
  7. a type cast to number


Example:

 
  // the following expressions are in any ring int expressions
  2 / 3;
==> // ** int division with `/`: use `div` instead in line >>  2 / 3;<<
==> 0
  4/ 8;
==> // ** int division with `/`: use `div` instead in line >>  4/ 8;<<
==> 0
  2 /2;   // the notation of / for div might change in the future
==> // ** int division with `/`: use `div` instead in line >>  2 /2;   // the\
    notation of / for div might change in the future<<
==> 1
  ring r0=0,x,dp;
  2/3, 4/8, 2/2 ; // are numbers
==> 2/3 1/2 1

  poly f = 2x2 +1;
  leadcoef(f);
==> 2
  typeof(_);
==> number
  ring rr =real,x,dp;
  1.7e-2; 1.7e+2; // are valid (but  1.7e2 not), if the field is `real`
==> (1.700e-02)
==> (1.700e+02)
  ring rp = (31,t),x,dp;
  2/3, 4/8, 2/2 ; // are numbers
==> 11 -15 1
  poly g = (3t2 +1)*x2 +1;
  leadcoef(g);
==> (3t2+1)
  typeof(_);
==> number
  par(1);
==> (t)
  typeof(_);
==> number
See Type conversion and casting; ring.