intmax

Largest value of an integer class.

Category: Language Fundamentals > Data Types

Syntax

m = intmax

Returns the largest int32.

m = intmax(classname)

Returns the largest value of the named integer class.

Description

Integer arithmetic saturates at this value: intmax('int32') + 1 is still intmax('int32'). For unsigned types the largest value is 2^n - 1, and for signed types 2^(n-1) - 1.

Input arguments

classname
One of 'int8', 'int16', 'int32' (default), 'int64', 'uint8', 'uint16', 'uint32', 'uint64'; or an integer array, whose class is used.

Output arguments

m
Scalar of the requested class.

Example

Limits of integer classes

intmax
intmax('uint16')
intmax('int64')
intmax('int32') + 1
Output
ans = int32
   2147483647
ans = uint16
   65535
ans = int64
   9223372036854775807
ans = int32
   2147483647

See also

intmin realmax flintmax int32 uint8