用C语言写一个程序,得出当前系统的整形数字长(16位,32位,64位)等,不能使用sizeof()
2024-08-21 05:24:10
#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;
}
最新文章
- RPC 使用中的一些注意点
- Find out files transfered via Bluetooth
- Linux压缩那些事儿
- python操作mongodb之基础操作
- POJ 3691 AC自动机上的dp
- 螺旋矩阵 noip2014普及组
- tornado学习精要
- 第五、六章:图像&;链接
- Codeforces Round #415(Div. 2)-810A.。。。 810B.。。。 810C.。。。不会
- AngularJS从入门到精通
- 从零开始unity特效(持续追加中)
- Uniform Generator HDU1014
- what&#39;s the 数据结构
- java.net.UnknownHostException: www.terracotta.org
- Mysql - 参数修改
- 基于redis分布式缓存实现(新浪微博案例)转
- Day 49 CSS样式.
- 基于mosquitto的MQTT服务器---SSL/TLS 单向认证+双向认证
- Android中Application类的使用
- <;Android 应用 之路>; 百度地图API使用(2)