安卓系统底层C语言算法之测试参数是几个long型的算法
2016-03-01 20:17
316 查看
#include <stdio.h>
#define BITS_PER_LONG (sizeof(unsigned long) * 8)
//求一个数x是几个long的长度
#define BITS_TO_LONGS(x) (((x) + BITS_PER_LONG - 1) / BITS_PER_LONG)
int main(void)
{
int i = 40 ;
int j = 1000 ;
printf("%d\n",BITS_TO_LONGS(i));
printf("%d\n",BITS_TO_LONGS(j));
return 0 ;
}
运行结果:
#define BITS_PER_LONG (sizeof(unsigned long) * 8)
//求一个数x是几个long的长度
#define BITS_TO_LONGS(x) (((x) + BITS_PER_LONG - 1) / BITS_PER_LONG)
int main(void)
{
int i = 40 ;
int j = 1000 ;
printf("%d\n",BITS_TO_LONGS(i));
printf("%d\n",BITS_TO_LONGS(j));
return 0 ;
}
运行结果:
相关文章推荐
- 安卓系统底层C语言算法之测试参数是几个long型的算法
- c++第一次实验
- C++常见面试题
- 位运算中的符号运算
- 分享个C++封装Libcurl代码(支持下载文件、GET\POST、重定向断点续传等功能)
- C语言实现单链表的逆序打印(带头结点)
- c++中string的用法积累
- C++面向对象编程分享----20160301_李楚煌
- C++指针的一些小总结
- Codeforces Round #338 (Div. 2) A. Bulbs (python and c++)
- C++ code 读取某给定路径下的当前文件夹名
- Effective C++ 读书笔记 条款1~2
- C语言实现单链表的节点插入(带头结点)
- 第三届蓝桥杯C++B组省赛
- 第四届蓝桥杯C++B组省赛
- 第五届蓝桥杯C++B组省赛
- 第六届蓝桥杯C++B组省赛
- C++::My Effective C++ (二)
- C++ virtual function (not pure virtual function)
- C++中常见问题处理