Ejemplo n.º 1
0
        /// <summary>
        /// Returns all bits in range as uint.
        /// </summary>
        /// <param name="pos">Position in bitfield (must be 0-31).</param>
        /// <param name="numBits">Number of bits to get (must be 1-32).</param>
        /// <returns>Returns requested range of bits.</returns>
        public uint GetBits(int pos, int numBits = 1)
        {
            CheckArgs(pos, numBits);
            var mask = 0xffffffffu >> (32 - numBits);

            return(Bitwise.ExtractBits(Value, pos, mask));
        }
Ejemplo n.º 2
0
        /// <summary>
        /// Returns true if all of bits in range are set.
        /// </summary>
        /// <param name="pos">Position in bitfield (must be 0-63).</param>
        /// <param name="numBits">Number of bits to set (must be 1-64).</param>
        /// <returns>Returns true if all bits are set.</returns>
        public bool TestAll(int pos, int numBits = 1)
        {
            CheckArgs(pos, numBits);
            var mask = 0xfffffffffffffffful >> (64 - numBits);

            return(mask == Bitwise.ExtractBits(Value, pos, mask));
        }