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