__builtin_popcount

__builtin_popcount(n)

计算32位二进制数中有多少个1

例:

n=63;//(111111)2

x=__builtin_popcount(n);

x=6;

 

posted @ 2019-01-30 09:53  6954717  阅读(343)  评论(0编辑  收藏  举报