# Documentation

### This is machine translation

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

# uint64

Convert to 64-bit unsigned integer

## Syntax

`intArray = uint64(array)`

## Description

`intArray = uint64(array)` converts the elements of an array into unsigned 64-bit (8-byte) integers of class `uint64`.

## Input Arguments

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

## Output Arguments

 `intArray` Array of class `uint64`. Values range from 0 to 264 – 1. The `uint64` function maps any values in `array` that are outside the limit to the nearest endpoint. For example, `uint64(2^64) % 2^64 = 18446744073709551616` returns ```ans = 18446744073709551615```

## Examples

Convert a literal value to `uint64`:

`x = uint64(9007199254740993);`

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

is not as efficient as

`I = zeros(100, 'uint64'); % Preferred `

collapse all

### Tall Array Support

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

### Tips

Double-precision floating-point numbers have only 52 bits in the mantissa. Therefore, `double` values cannot represent all integers greater than 253 correctly. Before performing arithmetic operations on values larger than 253 in magnitude, convert the values to 64-bit integers. For example,

`x = uint64(2^53+1); % Floating-point arithmetic, loses precision`

is not as accurate as the 64-bit integer arithmetic operation:

`x = uint64(2^53) + 1; % Preferred`