uint64
Converts values to unsigned 64-bit integers (0 to 18446744073709551615).
Category: Language Fundamentals > Data Types
Syntax
Y = uint64(X)
Converts X to class uint64.
Description
Values are rounded to the nearest integer and saturate at the limits of the type: negative numbers and NaN become 0. uint64 is the largest integer class, useful for counts and identifiers that do not fit in 32 bits.
A double has 53 bits of precision, so integers above 2^53 converted from double may not be exact; build large values from smaller integer parts when exactness matters.
Arithmetic with a double gives a uint64 result, rounded: uint64(10)/uint64(4) is 3.
Input arguments
X- Numeric, logical or char array.
Output arguments
Y- Array of class
uint64with the same size asX.
Example
Arithmetic and saturation at zero
a = uint64(10);
a/4
class(a*2)
uint64(-3)
uint64(2)^62
Output
ans = uint64
3
ans = 'uint64'
ans = uint64
0
ans = uint64
4611686018427387904
Notes
Values above 9223372036854775807 (the int64 maximum) saturate at that number, so intmax('uint64') does not reach 18446744073709551615.