public static int GetNumberOfLeadingZeros(uint n) { n = n | n >> 1; n = n | n >> 2; n = n | n >> 4; n = n | n >> 8; n = n | n >> 16; return(PopulationCount.GetPopulationCount(~n)); }
public static int GetPopulationCount(ulong n) { n = n | n >> 1; n = n | n >> 2; n = n | n >> 4; n = n | n >> 8; n = n | n >> 16; n = n | n >> 32; return(PopulationCount.GetPopulationCount(~n)); }
/// <summary> /// 立ってるビットの数を数える /// </summary> /// <param name="n">立ってるビットの数を数える</param> /// <returns></returns> public static long GetPopulationCount(long n) { return(PopulationCount.GetPopulationCount((ulong)n)); }
/// <summary> /// 立ってるビットの数を数える /// </summary> /// <param name="n">立ってるビットの数を数える</param> /// <returns></returns> public static long GetPopulationCount(int n) { return(PopulationCount.GetPopulationCount((uint)n)); }