intmax

intmax是一个编程函数。

Matlab中intmax简介

函数功能: 返回指定白腊匪喇整数类型所能表示的最大值。趋叠

调用格式:

v = intmax

返回matlab中灶少射32位正整数所能表示的正的最大值。

v = intmax('classname')

返回章键洪指定的整数类举蜜拜跨型所能表示己淋肯的正的最大值。'classname'可以是:

'int8'、'int16'、'int32'、'int64'、'uint8'、'uint16'、'uint32'、'uint64'。

相关函数: intmin

程局欠赠序示例

close all; clear; clc;

type_cell{1} = 'int';

type_cell{2} = 'uint';

bits = [8, 16, 32, 64];

for m = 1:2

for k = 1:4

type_str = strcat(type_cell{m}, num2str(bits(k)));

fprintf('The largest positive number ''%s'' can store is %s\n', ...

type_str, num2str(intmax(type_str)));

end

end

运行结果

The largest positive number 'int8' can store is 127

The largest positive number 'int16' can store is 32767

The largest positive number 'int32' can store is 2147483647

The largest positive number 'int64' can store is 9223372036854775800

The largest positive number 'uint8' can store is 255

The largest positive number 'uint16' can store is 65535

The largest positive number 'uint32' can store is 4294967295

The largest positive number 'uint64' can store is 18446744073709552000

上面这个程序打印出了matlab中各种整数类型所能表示的最大值。

相关词汇