安卓系统底层C语言算法之测试参数是几个long型的算法
程序员文章站
2022-03-29 15:54:10
#include
#define BITS_PER_LONG (sizeof(unsigned long) * 8)
//求一个数x是几个long的长度
#define B...
#include
#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 ;
}
运行结果: