Main Content

intmax

Largest value of specific integer type

Description

example

v = intmax returns the largest value of the 32-bit signed integer type.

example

v = intmax(type) returns the largest value of the specified integer type. When you convert a value that is larger than intmax(type) into the integer type type, the value becomes intmax(type).

example

v = intmax("like",p) returns the largest value of the integer type with the same data type and complexity (real or complex) as the integer variable p.

Examples

collapse all

Return the largest value of the 32-bit signed integer type.

v = intmax
v = int32
    2147483647

Return the largest value of the 64-bit unsigned integer type.

v = intmax("uint64")
v = uint64
    18446744073709551615

Check the class of v.

class(v)
ans = 
'uint64'

Return the largest value of the 8-bit signed integer type, which is 127.

v = intmax("int8")
v = int8
    127

Convert a value larger than 127 to 8-bit signed integer.

v1 = int8(198)
v1 = int8
    127

The converted value becomes 127.

Check that v1 is the same as v.

isequal(v,v1)
ans = logical
   1

Create a 2-by-3 complex array of 8-bit signed integers.

p = int8([-12 3+2i 2; 6 3 2-7i]);

Return the largest value of the integer type with the same data type and complexity as p.

v = intmax("like",p)
v = int8
    127 + 0i
class(v)
ans = 
'int8'

Input Arguments

collapse all

Integer type, specified as a character vector or string. This table shows the valid options for type.

Integer TypeDescription

"int8"

8-bit signed integer

"int16"

16-bit signed integer

"int32"

32-bit signed integer

"int64"

64-bit signed integer

"uint8"

8-bit unsigned integer

"uint16"

16-bit unsigned integer

"uint32"

32-bit unsigned integer

"uint64"

64-bit unsigned integer

Prototype, specified as an integer variable.

Data Types: int8 | int16 | int32 | int64 | uint8 | uint16 | uint32 | uint64
Complex Number Support: Yes

Extended Capabilities

C/C++ Code Generation
Generate C and C++ code using MATLAB® Coder™.

Version History

Introduced before R2006a