Example #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));
 }
Example #2
0
 public static int Pow2RoundDown(int x)
 {
     if (x < 0)
     {
         ExceptionUtil.ThrowArgumentOutOfRangeException("x", "must be non-negative");
     }
     return((int)UInt32Util.Pow2RoundDown((uint)x));
 }
Example #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));
 }
Example #4
0
 public static int RotateRight(int x, int count) =>
 ((int)UInt32Util.RotateRight((uint)x, count));
Example #5
0
 public static int HighestBit(int x) =>
 UInt32Util.HighestBit((uint)x);