Documentation Center

  • Trial Software
  • Product Updates
我们为许可用户提供了部分翻译好的中文文档。您只需登录便可查阅这些文档

uint32

Convert to 32-bit unsigned integer

Syntax

intArray = uint32(array)

Description

intArray = uint32(array) converts the elements of an array into unsigned 32-bit (4-byte) integers of class uint32.

Input Arguments

array

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

Output Arguments

intArray

Array of class uint32. Values range from 0 to 232 – 1.

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

uint32(2^32)   % 2^32 = 4294967296

returns

ans =
    4294967295

Examples

Convert a double array to uint32:

mydata = uint32(magic(1000));

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 = uint32(zeros(100));     % Creates an intermediate array

is not as efficient as

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

See Also

| | | | | | | | | |

Tutorials

Was this topic helpful?