码迷,mamicode.com
首页 > 其他好文 > 详细

int ,long , long long , __int64类型的范围

时间:2015-03-10 19:08:00      阅读:119      评论:0      收藏:0      [点我收藏+]

标签:

首先见测试代码(在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

 

int ,long , long long , __int64类型的范围

标签:

原文地址:http://www.cnblogs.com/CHLL55/p/4326733.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!