#include <iostream>
#include <cmath>
using namespace std;
int main()
{
    int num = -1;
    unsigned int  s = num;              //当前位级表示即为最大无符号数
    cout << (int)log2(s)+1 << endl; //第一种
    int intSize = 0;
    while(s != 0)
    {
        s = s >> 1;
        intSize = intSize + 1;
    }
    cout << intSize << endl; //循环处理也行
    int n = 1;        //直接用1,移位,,直到为0
    int cn = 0;
    while(n!=0)
    {
        n = (n << 1);
        cn++;
    }
    cout << cn<< endl;
    return 0;
}
用C语言写一个程序,得出当前系统的整形数字长(16位,32位,64位)等,不能使用sizeof()
原文:http://www.cnblogs.com/xlzhh/p/4415522.html