用stl打印极值
#include <iostream>
#include <limits>
#include <string>
using namespace std;
#define TRACEMAX(TYPENAME) {cout<<"MAX("<<#TYPENAME<<"):"<<numeric_limits<TYPENAME>::max()<<endl;}
int main(int argc, char** argv) {
cout<<boolalpha;
TRACEMAX(short)
TRACEMAX(int)
TRACEMAX(long)
TRACEMAX(long long)
cout<<endl;
TRACEMAX(float)
TRACEMAX(double)
TRACEMAX(long double)
return 0;
}
输出结果:在Ubuntu 7.04i386上
MAX(short):32767
MAX(int):2147483647
MAX(long):2147483647
MAX(long long):9223372036854775807
MAX(float):3.40282e+38
MAX(double):1.79769e+308
MAX(long double):1.18973e+4932
posted on 2007-09-25 21:20
zarra 阅读(122)
评论(0) 编辑 收藏