先用与、非操作使除最低位之外的数据置0,再用log2函数取值 int returnPosOfLow1(u_int& occ) { int n = occ; return log2(n & (~n + 1)); }