Exemple #1
0
 public static int Pow2RoundUp(int x)
 {
     if ((x < 0) || (x > 0x40000000))
     {
         ExceptionUtil.ThrowArgumentOutOfRangeException("x", "must be in the range [1, 2^30]");
     }
     return((int)UInt32Util.Pow2RoundUp((uint)x));
 }
Exemple #2
0
 public static int Pow2RoundDown(int x)
 {
     if (x < 0)
     {
         ExceptionUtil.ThrowArgumentOutOfRangeException("x", "must be non-negative");
     }
     return((int)UInt32Util.Pow2RoundDown((uint)x));
 }
Exemple #3
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));
 }
Exemple #4
0
 public static int RotateRight(int x, int count) =>
 ((int)UInt32Util.RotateRight((uint)x, count));
Exemple #5
0
 public static int HighestBit(int x) =>
 UInt32Util.HighestBit((uint)x);