# isinteger

Determine whether input is integer array

## Syntax

``TF = isinteger(A)``

## Description

example

````TF = isinteger(A)` 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

collapse all

Determine if a real number is an integer type.

`TF = isinteger(2)`
```TF = logical 0 ```

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.

`TF = isinteger(int8(2))`
```TF = logical 1 ```

Determine if a complex number is an integer type.

`A = 3.5 - 2.5i`
```A = 3.5000 - 2.5000i ```
`TF = isinteger(A)`
```TF = logical 0 ```

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.

`B = int32(A)`
```B = int32 4 - 3i ```
`TF = isinteger(B)`
```TF = logical 1 ```

When a number with decimal digits is converted to an integer type, MATLAB rounds it to the nearest integer.

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 = [int8(1:5)]`
```A = 1x5 int8 row vector 1 2 3 4 5 ```
`TF = isinteger(A)`
```TF = logical 1 ```

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]} ```
`type = class(B)`
```type = 'cell' ```
`TF = isinteger(B)`
```TF = logical 0 ```

The cell array is not an integer type since it is a cell type.

## Input Arguments

collapse all

Input array, specified as a scalar, vector, matrix, or multidimensional array. MATLAB has the following integer types.

Integer TypeDescription

`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` or `double` type, you can check if it is also an integer by using the `round` 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 logical `1` (`true`) since `2` is an integer.