예제 #1
0
 public static int Log2(int x)
 {
     if (x <= 0)
     {
         ExceptionUtil.ThrowArgumentOutOfRangeException("x", "must be positive");
     }
     if (x == 1)
     {
         return(0);
     }
     return(UInt32Util.HighestBit((uint)x));
 }
예제 #2
0
 public static int HighestBit(int x) =>
 UInt32Util.HighestBit((uint)x);