uint64 - 64-bit unsigned integer arrays - MATLAB (original) (raw)

Main Content

64-bit unsigned integer arrays

Description

Variables in MATLAB® of data type (class) uint64 are stored as 8-byte (64-bit) unsigned integers. For example:

Name Size Bytes Class Attributes

y 1x1 8 uint64

For more information on integer types, see Integers.

Creation

Some array creation functions allow you to specify the data type. For instance,zeros(100,'uint64') creates a 100-by-100 matrix of zeros of typeuint64.

If you have an array of a different type, such as double orsingle, then you can convert that array to an array of typeuint64 by using the uint64 function.

Syntax

Description

Y = uint64([X](#d126e1939463)) converts the values inX to type uint64. Values outside the range [0, 264–1] map to the nearest endpoint.

example

Input Arguments

expand all

Input array, specified as a scalar, vector, matrix, or multidimensional array.

Data Types: double | single | int8 | int16 | int32 | int64 | uint8 | uint16 | uint32 | logical | char

Examples

collapse all

Convert a double-precision variable to a 64-bit unsigned integer.

x = 100; xtype = class(x)

Convert an array of large integers (larger than flintmax) to a 64-bit unsigned integer array. When you specify a numeric array input, precision can be lost because MATLAB initially represents the input as double precision by default.

Y_inaccurate = uint64([72057594037539387 72057594037927935])

Y_inaccurate = 1×2 uint64 row vector

72057594037539384 72057594037927936

To maintain precision when creating a 64-bit unsigned integer array, call uint64 with each scalar element instead.

Y_accurate = [uint64(72057594037539387) uint64(72057594037927935)]

Y_accurate = 1×2 uint64 row vector

72057594037539387 72057594037927935

Starting in R2019b, you can also create the integer array accurately by using the hexadecimal or binary values of the integers. For more information, see Hexadecimal and Binary Values.

Y_accurate = [0xFFFFFFFFFA123Bu64 0xFFFFFFFFFFFFFFu64]

Y_accurate = 1×2 uint64 row vector

72057594037539387 72057594037927935

Tips

Extended Capabilities

expand all

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

The uint64 function fully supports GPU arrays. To run the function on a GPU, specify the input data as a gpuArray (Parallel Computing Toolbox). For more information, see Run MATLAB Functions on a GPU (Parallel Computing Toolbox).

Version History

Introduced before R2006a