All pastes #987046 Raw Edit

Untitled

public text v1 · immutable
·published 2008-04-16 04:37 UTC
rendered paste body
/// <summary>
    /// Gets the value and applies bitmask
    /// Shifts return value to line up with mask
    /// </summary>
    /// <param name="value">The value.</param>
    /// <returns></returns>
    public UInt64 GetMaskedValue(UInt64 value)
    {
        BitArray ba = new BitArray(this.bitMask);

        int maskCount = 0;
        foreach(bool testBit in ba)
        {
            if (testBit)
                break;
            maskCount++;
        }
        
        byte[] temp = new byte[8];
        bitMask.CopyTo(temp, 0);
        
        UInt64 mask = BitConverter.ToUInt64(bitMask, 0);

        UInt64 maskedValue = (value | mask) >> maskCount;
    }