BitsToHoldUInt() private method

private BitsToHoldUInt ( uint value ) : int
value uint
return int
        /// <summary>
        /// Reads a 32 bit integer value written using WriteRangedInteger()
        /// </summary>
        /// <param name="min">The minimum value used when writing the value</param>
        /// <param name="max">The maximum value used when writing the value</param>
        /// <returns>A signed integer value larger or equal to MIN and smaller or equal to MAX</returns>
        public int ReadRangedInteger(int min, int max)
        {
            uint range   = (uint)(max - min);
            int  numBits = NetUtility.BitsToHoldUInt(range);

            uint rvalue = ReadUInt32(numBits);

            return((int)(min + rvalue));
        }
        /// <summary>
        /// Writes an integer with the least amount of bits need for the specified range
        /// Returns number of bits written
        /// </summary>
        public int WriteRangedInteger(int min, int max, int value)
        {
            NetException.Assert(value >= min && value <= max, "Value not within min/max range!");

            uint range   = (uint)(max - min);
            int  numBits = NetUtility.BitsToHoldUInt(range);

            uint rvalue = (uint)(value - min);

            Write(rvalue, numBits);

            return(numBits);
        }