Write a function that takes an unsigned integer and returns the number of ’1' bits it has (also known as the Hamming weight). For example, the 32-bit integer...
Given an integer, write a function to determine if it is a power of two. 判断一个数是不是2的若干次幂?第一个想法,首个bit位为1,其余全为0.优美解法:只有2的若干次幂和自身减1的每一个bit位不同,所以n &(n-1) != 0 说明...