符号属性 长度属性 基本型 所占位数 取值范围 输入符举例 输出符举例
-- -- char 8 -2^7 ~ 2^7-1 %c %c、%d、%usigned -- char 8 -2^7 ~ 2^7-1 %c %c、%d、%uunsigned -- char 8 0 ~ 2^8-1 %c %c、%d、%u
[signed] short [int] 16 -2^15 ~ 2^15-1 %hdunsigned short [int] 16 0 ~ 2^16-1 %hu、%ho、%hx
[signed] -- int 32 -2^31 ~ 2^31-1 %dunsigned -- [int] 32 0 ~ 2^32-1 %u、%o、%x
[signed] long [int] 32 -2^31 ~ 2^31-1 %ldunsigned long [int] 32 0 ~ 2^32-1 %lu、%lo、%lx
[signed] long long [int] 64 -2^63 ~ 2^63-1 %I64dunsigned long long [int] 64 0 ~ 2^64-1 %I64u、%I64o、%I64x
-- -- float 32 +/- 3.40282e+038 %f、%e、%g-- -- double 64 +/- 1.79769e+308 %lf、%le、%lg %f、%e、%g-- long double 96 +/- 1.79769e+308 %Lf、%Le、%Lg
#include#include using namespace std;int main(){ //bool cout << "bool: \t\t" << "所占字节数:" << sizeof(bool); cout << "\t最大值:" << (numeric_limits ::max)(); cout << "\t\t最小值:" << (numeric_limits ::min)() << endl; //char cout << "char: \t\t" << "所占字节数:" << sizeof(char); cout << "\t最大值:" << (numeric_limits ::max)(); cout << "\t\t最小值:" << (numeric_limits ::min)() << endl; //signed char cout << "signed char: \t" << "所占字节数:" << sizeof(signed char); cout << "\t最大值:" << (numeric_limits ::max)(); cout << "\t\t最小值:" << (numeric_limits ::min)() << endl; //unsigned char cout << "unsigned char: \t" << "所占字节数:" << sizeof(unsigned char); cout << "\t最大值:" << (numeric_limits ::max)(); cout << "\t\t最小值:" << (numeric_limits ::min)() << endl; //wchar_t cout << "wchar_t: \t" << "所占字节数:" << sizeof(wchar_t); cout << "\t最大值:" << (numeric_limits ::max)(); cout << "\t\t最小值:" << (numeric_limits ::min)() << endl; //short cout << "short: \t\t" << "所占字节数:" << sizeof(short); cout << "\t最大值:" << (numeric_limits ::max)(); cout << "\t\t最小值:" << (numeric_limits ::min)() << endl; //int cout << "int: \t\t" << "所占字节数:" << sizeof(int); cout << "\t最大值:" << (numeric_limits ::max)(); cout << "\t最小值:" << (numeric_limits ::min)() << endl; //unsigned cout << "unsigned: \t" << "所占字节数:" << sizeof(unsigned); cout << "\t最大值:" << (numeric_limits ::max)(); cout << "\t最小值:" << (numeric_limits ::min)() << endl; //long cout << "long: \t\t" << "所占字节数:" << sizeof(long); cout << "\t最大值:" << (numeric_limits ::max)(); cout << "\t最小值:" << (numeric_limits ::min)() << endl; //unsigned long cout << "unsigned long: \t" << "所占字节数:" << sizeof(unsigned long); cout << "\t最大值:" << (numeric_limits ::max)(); cout << "\t最小值:" << (numeric_limits ::min)() << endl; //float cout << "float: \t\t" << "所占字节数:" << sizeof(float); cout << "\t最大值:" << (numeric_limits ::max)(); cout << "\t最小值:" << (numeric_limits ::min)() << endl; //size_t cout << "size_t: \t" << "所占字节数:" << sizeof(size_t); cout << "\t最大值:" << (numeric_limits ::max)(); cout << "\t最小值:" << (numeric_limits ::min)() << endl; //double cout << "double: \t" << "所占字节数:" << sizeof(double); cout << "\t最大值:" << (numeric_limits ::max)(); cout << "\t最小值:" << (numeric_limits ::min)() << endl; //long long cout << "long long: \t" << "所占字节数:" << sizeof(long long); cout << "\t最大值:" << (numeric_limits ::max)(); cout << "\t最小值:" << (numeric_limits ::min)() << endl; //long double cout << "long double: \t" << "所占字节数:" << sizeof(long double); cout << "\t最大值:" << (numeric_limits ::max)(); cout << "\t最小值:" << (numeric_limits ::min)() << endl; return 0;}