include<climits>
using namespace std;
short a=3;
int b=100;
long c=900'
long long d=100;
cout <<INT_MAX<<endl;
cout <<INT_MIN<<endl;
cout<<SHRT_MAX<<endl;
cout <<SHRT_MIN<<endl;
变量越大占用内存越大。
int!
include<climits>
using namespace std;
short a=3;
int b=100;
long c=900'
long long d=100;
cout <<INT_MAX<<endl;
cout <<INT_MIN<<endl;
cout<<SHRT_MAX<<endl;
cout <<SHRT_MIN<<endl;
变量越大占用内存越大。
int!
整形类型分为四种类型
short
int
long
longlong
int型最大值和最小值
cout<<"INT_MAX"<<endl;
cout<<"INT_MIN<<endl;
short型最大值和最小值
cout<<SHRT_MAX<<endl;
cout<<SHRT_MIN<<endl;
long型最大值和最小值
cout<<LONG_MAX<<endl;
cout<<LONG_MIN<<endl;
long long 型最大值最小值
cout<<"LONG_LONG_MAX";
cout<<LONG_LONG_MAX<<endl;
cout<<"LONG_LONG_MIN";
cout <<LONG_LONG_MIN<<endl;
unsigned 表示无符号的
其他数据类型
整数
short
int
long
long long
unsignde int=数值大于等于0且数值翻倍
short
int
long
long long
整数类型
unsigned int 无符号的数 (负数) 正数翻倍cun'cu
关键字 unsigned 定义整型 代表无符号
short整形 int一个亿都可以存储
short 比较小的数据 INT32_Max多少位
min单位
short类型是3w int类型是20亿
long类型是上百亿
unsigned short e =无符号的
命名规则,类型 + 字符串
类型存在范围,不能超出范围
unsigned 使数据无符号,不能存在负数
#include <iostream>
#include <climits>
using namespace std;
int main()
{
// 类似:超市购物买袋子,袋子大小放的东西多大
short a = 3;
int b = 100;
long c = 900;
long long d = 100;
cout << INT_MAX << endl; // 输出:2147483647 // 21亿
cout << INT_MAX << endl; // 输出:-2147483648
cout << SHRT_MAX << endl; // 输出:32767 // 3万
cout << SHRT_MAX << endl; // 输出:-32768
short level = 8;
unsigned short e = 3; // unsigned 无符号的
// unsigned short e = -3;
// cout << e << endl; // 输出:65533
// unsigned short 类型 范围:0~65535
// 0 65535 65534 65533
// 0 -1 -2 -3
// int b = 100000000000;
// cout << b << endl; // 输出:1215752192
int b = 400000000;
unsigned int f = 4000000000; // unsigned 比原来扩大2倍
cout << b << endl; // 输出:-294967296
cout << f << endl; // 输出:4000000000
int t;
cin >> t;
return 0;
}
百度:
C++ 整形 范围