编译器的字节范围测试

来源:互联网 发布:node.exe是什么东西 编辑:程序博客网 时间:2024/05/22 12:30
#include<iostream>
#include<climits>
int main()
{
    using namespace std;
    int n_int=INT_MAX;
    short n_short=SHRT_MAX;
    long n_long=LONG_MAX;
    long long n_llong=LLONG_MAX;
    cout << "int is " << sizeof(int) << endl;
    cout << "short is " << sizeof(short) << endl;
    cout << "long is " << sizeof(long) << endl;
    cout << "long long is " << sizeof(long long) << endl;
    cout << endl;
    cout << "maximum value:"<< endl;
    cout << "int: " << n_int << endl;
    cout << "short: " << n_short << endl;
    cout << "long: " << n_long << endl;
    cout << "long long: " << n_llong << endl;
    cout << "minimum int value:"<< endl;
    cout << INT_MIN << endl;
    cout << "bite per byte= " << CHAR_BIT << endl;
}