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