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).

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

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

Extended Capabilities

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

See Also

| | | |

Introduced before R2006a