安卓系统底层C语言算法之測试參数是几个long型的算法

#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 ",BITS_TO_LONGS(i));
printf("%d ",BITS_TO_LONGS(j));
return 0 ;

}

执行结果:


原文地址:https://www.cnblogs.com/yutingliuyl/p/7095062.html