isinteger

Tests whether an array has an integer class.

Category: Language Fundamentals > Data Types

Syntax

tf = isinteger(A)

Returns true if A is of class int8, int16, int32, int64, uint8, uint16, uint32 or uint64.

Description

The test is about the class, not the value. The double 3 holds a whole number but isinteger(3) is false; isinteger(int8(3)) is true. To check whether values are whole numbers, compare with round, for instance x == round(x).

Input arguments

A
Any value.

Output arguments

tf
Logical scalar.

Example

Class versus value

isinteger(int8(3))
isinteger(3)
x = [1 2.5 4];
x == round(x)
Output
ans = logical
   1
ans = logical
   0
ans = 1×3 logical array

   1   0   1

See also

isfloat isnumeric round int8