- /*
- coder: ACboy
- date: 2010-3-1
- */
- #include <iostream>
- #include <float.h>
- using namespace std;
- int main()
- {
- cout << "int 类型能存储的最大值和最小值" << endl;
- cout << "INT_MAX = " << INT_MAX << endl;
- cout << "INT_MIN = " << INT_MIN << endl;
- cout << "long 类型能存储的最大值和最小值" << endl;
- cout << "LONG_MAX = " << LONG_MAX << endl;
- cout << "LONG_MIN = " << LONG_MIN << endl;
- cout << "long long 类型能存储的最大值和最小值" << endl;
- cout << "LONG_LONG_MAX = " << LONG_LONG_MAX << endl;
- cout << "LONG_LONG_MIN = " << LONG_LONG_MIN << endl;
- cout << "float 类型能存储的最大值和最小值" << endl;
- cout << "FLT_MAX = " << FLT_MAX << endl;
- cout << "FLT_MIN = " << FLT_MIN << endl;
- cout << "double 类型能存储的最大值和最小值" << endl;
- cout << "DBL_MAX = " << DBL_MAX << endl;
- cout << "DBL_MIN = " << DBL_MIN << endl;
- return 0;
- }
从运行结果看:
int和long都是用32位来存储最大值和最小值分别为2147483647(109), -2147483648;
long long 是用64位来存储最大值和最小值分别为9223372036854775807(1018),-9223372036854775808;
float的最大值和最小值分别为3.40282e+038(1038),1.17549e-038(10-38);
double的最大值和最小值分别为1.79769e+308(10308),2.22507e-308(10-308)。