Example #1
0
 public static int Pow2RoundDown(int x)
 {
     if (x < 0)
     {
         ExceptionUtil.ThrowArgumentOutOfRangeException("x", "must be non-negative");
     }
     return((int)UInt32Util.Pow2RoundDown((uint)x));
 }
Example #2
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 #3
0
 public static bool IsClamped(double value, double min, double max)
 {
     if (min > max)
     {
         ExceptionUtil.ThrowArgumentOutOfRangeException("min", "min must be less than or equal to max");
     }
     return((value >= min) && (value <= max));
 }
Example #4
0
 public static unsafe int Log2(byte x)
 {
     if (x == 0)
     {
         ExceptionUtil.ThrowArgumentOutOfRangeException("x", "must be 1 or greater");
     }
     return(pHighestBitLookup[x]);
 }
Example #5
0
 public static int Log2RoundUp(uint x)
 {
     if ((x == 0) || (x > 0x80000000))
     {
         ExceptionUtil.ThrowArgumentOutOfRangeException("x must be in the range [1, 2^31]");
     }
     return(Log2((x - 1) + x));
 }
Example #6
0
 public static int Log2(uint x)
 {
     if (x == 0)
     {
         ExceptionUtil.ThrowArgumentOutOfRangeException("x", "must be 1 or greater");
     }
     return(HighestBit(x));
 }
Example #7
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 #8
0
 public static uint Pow2RoundUp(uint x)
 {
     if (x > 0x80000000)
     {
         ExceptionUtil.ThrowArgumentOutOfRangeException("x", "must be less than or equal to 2^31");
     }
     if (x == 0)
     {
         return(1);
     }
     return(Pow2RoundUpNonZero(x));
 }
Example #9
0
 public static unsafe void CopyElements(void *pDst, void *pSrc, int srcLength, int srcIndex, int elementCount, int elementSize)
 {
     if ((pDst == null) || (pSrc == null))
     {
         ExceptionUtil.ThrowArgumentNullException();
     }
     if (((srcLength < 0) || (srcIndex < 0)) || (((elementCount < 0) || (elementSize < 1)) || ((srcIndex + elementCount) > srcLength)))
     {
         ExceptionUtil.ThrowArgumentOutOfRangeException();
     }
     if (elementCount != 0)
     {
         Buffer.MemoryCopy(pSrc + ((void *)(srcIndex * elementSize)), pDst, (long)(elementCount * elementSize), (long)(elementCount * elementSize));
     }
 }
Example #10
0
 private static void IsClampedThrow(long value, long min, long max)
 {
     ExceptionUtil.ThrowArgumentOutOfRangeException("min", $"min must be less than or equal to max. value={value}, min={min}, max={max}");
 }
Example #11
0
 private static void ClampThrow(int value, int min, int max)
 {
     ExceptionUtil.ThrowArgumentOutOfRangeException("min", $"min must be less than or equal to max. value={value}, min={min}, max={max}");
 }