int ,long , long long , __int64类型的范围
首先见测试代码(在g++/gcc下运行):
#include<iostream> using namespace std; int main() { cout<<sizeof(int)<<endl; cout<<sizeof(unsigned int)<<endl; cout<<sizeof(long)<<endl; cout<<sizeof(unsigned long)<<endl; cout<<sizeof(long long)<<endl; cout<<sizeof(unsigned long long)<<endl; cout<<sizeof(__int64)<<endl; cout<<sizeof(unsigned __int64)<<endl; return 0; }
运行结果为:4 4 4 4 8 8 8 8(均为字节)
有结果可知:int , long , long long , __int64的范围如下:
int -2147483648~2147483647
unsigned int 0~4294967295
long -2147483648~2147483647
unsigned long 0~4294967295
long long -9223372036854775808~9223372036854775807
unsigned long long的最大值:18446744073709551615
__int64 -9223372036854775808~9223372036854775807
unsigned __int64的最大值:18446744073709551615