Main Content

int32

32-bit signed integer arrays

Description

Variables in MATLAB® of data type (class) int32 are stored as 4-byte (32-bit) signed integers. For example:

y = int32(10);
whos y
  Name      Size            Bytes  Class    Attributes

  y         1x1                 4  int32                 

For more information on integer types, see Integers.

Creation

Some array creation functions allow you to specify the data type. For instance, zeros(100,'int32') creates a 100-by-100 matrix of zeros of type int32.

If you have an array of a different type, such as double or single, then you can convert that array to an array of type int32 by using the int32 function.

Description

example

Y = int32(X) converts the values in X to type int32. Values outside the range [-231,231-1] map to the nearest endpoint.

Input Arguments

expand all

Input array, specified as a scalar, vector, matrix, or multidimensional array.

Data Types: double | single | int8 | int16 | int64 | uint8 | uint16 | uint32 | uint64 | logical | char

Examples

collapse all

Convert a double-precision variable to a 32-bit signed integer.

x = 100;
xtype = class(x)
xtype = 
'double'
y = int32(x)
y = int32
    100

Extended Capabilities

C/C++ Code Generation
Generate C and C++ code using MATLAB® Coder™.

GPU Code Generation
Generate CUDA® code for NVIDIA® GPUs using GPU Coder™.

Version History

Introduced before R2006a