int64

Converts values to signed 64-bit integers, from -9223372036854775808 to 9223372036854775807.

Category: Language Fundamentals > Data Types

Syntax

B = int64(A)

Converts A to class int64.

Description

Fractions are rounded to the nearest integer, with ties going away from zero. Out-of-range values saturate at intmin('int64') or intmax('int64') instead of wrapping around, and NaN becomes 0. Arithmetic between a int64 and a double gives a int64, rounded after the operation; mixing two different integer classes is an error.

The class has no representation for Inf or NaN, so int64(Inf) is intmax('int64').

Input arguments

A
Numeric, logical or char array.

Output arguments

B
Array of class int64, same size as A.

Example

Rounding and saturation

int64(9223372036854775807)
int64(2)^62
int64(1e19)
class(int64(3))
Output
ans = int64
   9223372036854775807
ans = int64
   4611686018427387904
ans = int64
   9223372036854775807
ans = 'int64'

See also

intmax intmin double uint8 round cast