2.6 Integer Matrices

There are 6 integer data types defined in Scilab, all these types have the same major type (see the type function) which is 8 and different sub-types (see the inttype function)

It is possible to build these integer data types from standard matrix (see 2.2) using the int32, uint32, int16, uint16, int8, uint8 conversion functions
-->x=[0 3.2 27 135] ;

-->int32(x)
 ans  =
 
!0   3  27  135 !

-->int8(x)
 ans  =
 
!0   3  27  -121!
-->uint8(x)
 ans  =
 
!0   3  27  135 !

The same function can also convert from one sub-type to another one. The double function transform any of the integer type in a standard type:

-->y=int32([2 5 285])
 y  =
 
!2  5  285 !

-->uint8(y)
 ans  =
 
!2  5  29 !

-->double(ans)
 ans  =
 
!   2.    5.    29. !

Arithmetic and comparison operations can be applied to this type

-->x=int16([1 5 12])
 x  =
 
!1  5  12 !

-->x([1 3])
 ans  =
 
!1  12 !
 
-->x+x

 ans  =
 
!2  10  24 !

-->x*x'             
 ans  =
 
 170
-->y=int16([1 7 11])
 y  =
 
!1  7  11 !
-->x>y
 ans  =
 
! F F T !

The operators &, | and   used with these datatypes correspond to AND, OR and NOT bit-wise operations.

-->x=int16([1 5 12])
 x  =
 
!1  5  12 !
 
-->x|int16(2)
 ans  =
 
!3  7  14 !

-->int16(14)&int16(2)
 ans  =
 
 2  
-->~uint8(2)
 ans  =
 
 253