[ << ] [ < ] [ Up ] [ > ] [ >> ] [Top] [Contents] [Index] [ ? ]

## 6.8 Types

 [ << ] [ < ] [ Up ] [ > ] [ >> ] [Top] [Contents] [Index] [ ? ]

### 6.8.1 `type`

type(obj)

:: Returns an integer which identifies the type of the object obj in question.

return

integer

obj

arbitrary

• Current assignment of integers for object types is listed below.
0

0

1

number

2

polynomial (not number)

3

rational expression (not polynomial)

4

list

5

vector

6

matrix

7

string

8

structure

9

distributed polynomial

10

32bit unsigned integer

11

error object

12

matrix over GF(2)

13

MATHCAP object

14

first order formula

-1

VOID object

• For further classification of number, use `ntype()`. For further classification of variable, use `vtype()`.
References

 [ << ] [ < ] [ Up ] [ > ] [ >> ] [Top] [Contents] [Index] [ ? ]

### 6.8.2 `ntype`

ntype(num)

:: Classifier of type num. Returns a sub-type number, an integer, for obj.

return

integer

obj

number

• Sub-types for type number are listed below.
0

rational number

1

floating double (double precision floating point number)

2

algebraic number over rational number field

3

arbitrary precision floating point number (bigfloat)

4

complex number

5

element of a finite field

6

element of a large finite prime field

7

element of a finite field of characteristic 2

• When arithmetic operations for numbers are performed, type coercion will be taken if their number sub-types are different so that the object having smaller sub-type number will be transformed to match the other object, except for algebraic numbers.
• A number object created by `newalg(x^2+1)` and the unit of imaginary number `@i` have different number sub-types, and it is treated independently.
• See Algebraic numbers for algebraic numbers.
``` [10/37,ntype(10/37)];
[10/37,0]
 [10.0/37.0,ntype(10.0/37.0)];
[0.27027,1]
 [newalg(x^2+1)+1,ntype(newalg(x^2+1)+1)];
[(#0+1),2]
 [eval(sin(@pi/6)),ntype(eval(sin(@pi/6)))];
[0.49999999999999999991,3]
 [@i+1,ntype(@i+1)];
[(1+1*@i),4]
```
References

 [ << ] [ < ] [ Up ] [ > ] [ >> ] [Top] [Contents] [Index] [ ? ]

### 6.8.3 `vtype`

vtype(var)

:: Type of indetarminates var.

return

integer

var

indeterminate

• Classify indeterminates into sub-types by giving an integer value as follows. For details See section Types of indeterminates.
0

ordinary indeterminate, which can be directly typed in on a keyboard (a,b,x,afo,bfo,...,etc.)

1

Special indeterminate, created by `uc()` (`_0`, `_1`, `_2`, ... etc.)

2

function form (`sin(x)`, `log(a+1)`, `acosh(1)`, `@pi`, `@e`, ... etc.)

3

functor (built-in functor name, user defined functor, functor for the elementary functions) : `sin`, `log`, ... etc)

• Note: An input ‘`a();`’ will cause an error, but it changes the system database for identifiers. After this error, you will find ‘`vtype(a)`’ will result 3. (Identifier `a` is registered as a user defined functor).
• Usually `@pi` and `@e` are treated as indeterminates, whereas they are treated as numbers within functions `eval()` and `pari()`.
References

 [ << ] [ < ] [ Up ] [ > ] [ >> ]

This document was generated on September 27, 2023 using texi2html 5.0.