|
FreeMat
|
Section: Type Conversion Functions
Converts the argument to an unsigned 64-bit Integer. The syntax for its use is
y = uint64(x)
where x is an n-dimensional numerical array. Conversion follows saturation rules (e.g., if x is outside the normal range for an unsigned 64-bit integer of [0,2^64-1], it is truncated to that range. Note that both NaN and Inf both map to 0.
The following piece of code demonstrates several uses of uint64.
--> uint64(200) ans = 200
In the next example, an integer outside the range of the type is passed in. The result is truncated to the maximum value of the data type.
--> uint64(40e9) ans = 40000000000
In the next example, a negative integer is passed in. The result is zero.
--> uint64(-100) ans = 0
In the next example, a positive double precision argument is passed in. The result is the unsigned integer that is closest to the argument.
--> uint64(pi) ans = 3
In the next example, a complex argument is passed in. The result is the complex unsigned integer that is closest to the argument.
--> uint64(5+2*i) ans = 5.0000 + 2.0000i
In the next example, a string argument is passed in. The string argument is converted into an integer array corresponding to the ASCII values of each character.
--> uint64('helo')
ans =
104 101 108 111
In the last example, a cell-array is passed in. For cell-arrays and structure arrays, the result is an error.
--> uint64({4})
Error: Cannot perform type conversions with this type