#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;
}
时间: 2024-10-20 12:35:31