Documentation

This is machine translation

Translated by Microsoft
Mouse over text to see original. Click the button below to return to the English verison of the page.

라이선스가 부여된 사용자만 번역 문서를 볼 수 있습니다. 번역 문서를 보려면 로그인하십시오.

int8

Convert to 8-bit signed integer

Syntax

intArray = int8(array)

Description

intArray = int8(array) converts the elements of an array into signed 8-bit (1-byte) integers of class int8.

Input Arguments

array

Array of any numeric class, such as single or double. If array is already of class int8, the int8 function has no effect.

Output Arguments

intArray

Array of class int8. Values range from –27 to 27 – 1.

The int8 function maps any values in array that are outside the limit to the nearest endpoint. For example,

int8(2^7)   % 2^7 = 128

returns

ans =
    127

Examples

Convert a double array to int8:

mydata = int8(magic(10));

Related Examples

Alternatives

When preallocating integer arrays, specify the class in the call to functions that support a class name input (such as zeros, ones or eye), rather than calling an integer conversion function. For example,

I = int8(zeros(100));     % Creates an intermediate array

is not as efficient as

I = zeros(100, 'int8');   % Preferred 

More About

collapse all

Tall Array Support

This function fully supports tall arrays. For more information, see Tall Arrays.

Introduced before R2006a

Was this topic helpful?