1. 程式人生 > >常用整型變數的最大取值範圍

常用整型變數的最大取值範圍

#include<iostream>
#include<math.h>
#include<limits.h>
using namespace std;

int main()
{
	// 2^16 = 32768 : unsigned short
	// 2^32 = 4.29497e+009 : unsigned int, long
	// 2^64 = 1.84467e+019 : unsigned long long
	// SHRT_MAX = 32767 (3.2e+004): short
	// INT_MAX = 2147483647 (2.1e+009) : int 
	// LONG_MAX = 2147483647 (2.1e+009) : long
	// LONG_LONG_MAX = 9.2e+018 : long long
	
	cout << pow(2,31) << endl;
	cout << SHRT_MAX << endl;
	cout << INT_MAX << endl;
	cout << LONG_MAX << endl;
	 
	return 0;
	
}