isinteger - Determine whether input is integer array - MATLAB (original) (raw)
Main Content
Determine whether input is integer array
Syntax
Description
`TF` = isinteger([A](#mw%5F24862503-d61c-4de8-88ce-3c8580dc0300))
returns logical 1
(true
) if A
is an array of integer type. Otherwise, it returns logical 0
(false
).
Integer types in MATLAB® include: int8
, int16
,int32
, int64
, uint8
,uint16
, uint32
, and uint64
. For more information, see Integer Classes.
Examples
Determine Whether Real Number Is Integer Type
Determine if a real number is an integer type.
MATLAB® stores a real number as a double
type by default.
Convert the number to a signed 8-bit integer type using the int8 function. Check if it is an integer type.
Determine Whether Complex Number Is Integer Type
Determine if a complex number is an integer type.
MATLAB stores a complex number as a double
type by default.
Convert the complex number into a signed 32-bit integer type using the int32 function. Check if it is an integer type.
When a number with decimal digits is converted to an integer type, MATLAB rounds it to the nearest integer.
Determine Whether Arrays Are Integer Type
Determine if an array containing integer numbers is an integer type.
Create an array using the int8 function. Check if it is an integer type.
A = 1x5 int8 row vector
1 2 3 4 5
Now, create a cell array that contains the array A
and other integer numbers. Use class to identify the type of the cell array. Check if it is an integer type.
B = {A int8(-4); int8(2) int8(1)}
B=2×2 cell array {[1 2 3 4 5]} {[-4]} {[ 2]} {[ 1]}
The cell array is not an integer type since it is a cell type.
Input Arguments
A
— Input array
scalar | vector | matrix | multidimensional array
Input array, specified as a scalar, vector, matrix, or multidimensional array. MATLAB has the following integer types.
Integer Type | Description |
---|---|
int8 | 8-bit signed integer |
int16 | 16-bit signed integer |
int64 | 64-bit signed integer |
int32 | 32-bit signed integer |
uint8 | 8-bit unsigned integer |
uint16 | 16-bit unsigned integer |
uint32 | 32-bit unsigned integer |
uint64 | 64-bit unsigned integer |
Tips
- For a floating-point number of a
single
ordouble
type, you can check if it is also an integer by using theround function (within the floating-point relative accuracy eps). If the rounded value of the number is equal to the original value before rounding, then the number is an integer. For example,2 == round(2)
returns logical1
(true
) since2
is an integer.
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™.
Thread-Based Environment
Run code in the background using MATLAB® backgroundPool
or accelerate code with Parallel Computing Toolbox™ ThreadPool
.
This function fully supports thread-based environments. For more information, see Run MATLAB Functions in Thread-Based Environment.
GPU Arrays
Accelerate code by running on a graphics processing unit (GPU) using Parallel Computing Toolbox™.
The isinteger
function fully supports GPU arrays. To run the function on a GPU, specify the input data as a gpuArray (Parallel Computing Toolbox). For more information, see Run MATLAB Functions on a GPU (Parallel Computing Toolbox).
Distributed Arrays
Partition large arrays across the combined memory of your cluster using Parallel Computing Toolbox™.
This function fully supports distributed arrays. For more information, see Run MATLAB Functions with Distributed Arrays (Parallel Computing Toolbox).
Version History
Introduced before R2006a