Esempio n. 1
0
 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));
 }
Esempio n. 2
0
 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));
 }
Esempio n. 3
0
 /// <summary>
 /// 立ってるビットの数を数える
 /// </summary>
 /// <param name="n">立ってるビットの数を数える</param>
 /// <returns></returns>
 public static long GetPopulationCount(long n)
 {
     return(PopulationCount.GetPopulationCount((ulong)n));
 }
Esempio n. 4
0
 /// <summary>
 /// 立ってるビットの数を数える
 /// </summary>
 /// <param name="n">立ってるビットの数を数える</param>
 /// <returns></returns>
 public static long GetPopulationCount(int n)
 {
     return(PopulationCount.GetPopulationCount((uint)n));
 }