MATLAB Function Reference
int8, int16, int32, int64

Convert to signed integer

Syntax

• ```i = int8(x)
i = int16(x)
i = int32(x)
i = int64(x)
```

Description

```i = int*(x) ``` converts the vector `x` into a signed integer. `x` can be any numeric object (such as a `double`). The results of an `int*` operation are shown in the next table.

 Operation Output Range Output Type Bytes per Element Output Class `int8` -128 to 127 Signed 8-bit integer 1 `int8` `int16` -32,768 to 32,767 Signed 16-bit integer 2 `int16` `int32` -2,147,483,648 to 2,147,483,647 Signed 32-bit integer 4 `int32` `int64` -9,223,372,036,854,775,808 to 9,223,372,036,854,775,807 Signed 64-bit integer 8 `int64`

A value of `x` above or below the range for a class is mapped to one of the endpoints of the range. If `x` is already a signed integer of the same class, `int*` has no effect.

The `int*` class is primarily meant to store integer values. Most operations that manipulate arrays without changing their elements are defined. (Examples are `reshape`, `size`, the logical and relational operators, subscripted assignment, and subscripted reference.) No math operations except for `sum` are defined for `int*` since such operations are ambiguous on the boundary of the set. (For example, they could wrap or truncate there.) You can define your own methods for `int*` (as you can for any object) by placing the appropriately named method in an `@int*` directory within a directory on your path.

Type `help datatypes` for the names of the methods you can overload.

See Also

`double`, `single`, `uint8`, `uint16`, `uint32`, `uint64`

 int2str interp1