int32
Converts values to signed 32-bit integers, from -2147483648 to 2147483647.
Category: Language Fundamentals > Data Types
Syntax
B = int32(A)
Converts A to class int32.
Description
Fractions are rounded to the nearest integer, with ties going away from zero. Out-of-range values saturate at intmin('int32') or intmax('int32') instead of wrapping around, and NaN becomes 0. Arithmetic between a int32 and a double gives a int32, rounded after the operation; mixing two different integer classes is an error.
The class has no representation for Inf or NaN, so int32(Inf) is intmax('int32').
Input arguments
A- Numeric, logical or char array.
Output arguments
B- Array of class
int32, same size asA.
Example
Rounding and saturation
int32(5) / int32(2)
int32(7) / 2
int32(1e10)
int32(NaN)
class(int32(3))
Output
ans = int32
3
ans = int32
4
ans = int32
2147483647
ans = int32
0
ans = 'int32'