得到系统位数限制

/*----------------------------------------------------*/
/*显示当前系统的位数限制,如整形,浮点型等            */
/*By Edison Wang              DATE:2009-07-22         */

#include <iostream>
#include <climits>
#include <cfloat>
using namespace std;

int main(){
//Print integer type maxima.
cout << "short maximum: " <<SHRT_MAX <<endl;
cout << "int maximum: "<<INT_MAX <<endl;
cout << "long maximum: "<<LONG_MAX <<endl << endl;

//Print float precision,range,maximum.
cout << "float precision digits: " << FLT_DIG <<endl;
cout << "float maximum exponent: "<<FLT_MAX_10_EXP <<endl;
cout << "float maximum: "<<FLT_MAX <<endl <<endl;

//Print double precision,range,maximum.
cout << "double precision digits: " << DBL_DIG <<endl;
cout << "double maximum exponent: "<<DBL_MAX_10_EXP <<endl;
cout << "double maximum: "<<DBL_MAX <<endl <<endl;

//Print long precision,range,maximum.
cout << "long precision digits: " << LDBL_DIG <<endl;
cout << "long maximum exponent: "<<LDBL_MAX_10_EXP <<endl;
cout << "long maximum: "<<LDBL_MAX <<endl <<endl;

return 0;
}

posted @ 2009-08-12 06:11  莫忆往西  阅读(139)  评论(0)    收藏  举报