Exemple #1
0
        public static uint PutBitsAsLSB(this uint value, BitArray bitsToPut)
        {
            int result = (int)value & shiftDictionary[bitsToPut.Length];

            value = value - (uint) result;

            var valueToAdd = (uint) bitsToPut.GetIntFromBitArray();

            return value + valueToAdd;
        }
Exemple #2
0
        public static int GetIntFromByteArray(this byte[] array)
        {
            BitArray bitsToReturn = new BitArray(array.Length * 8);

            for (int i = 0; i < array.Length; i++)
            {
                var bitsFromByte = new BitArray(new[] { array[i] });

                for (int j = 0; j < 8; j++)
                {
                    bitsToReturn.Set((j + i * 8), bitsFromByte[j]);
                }
            }

            var result = bitsToReturn.GetIntFromBitArray();

            return result;
        }
 public NaturalIntHasBits(BitArray bits)
 {
     Condition.Requires(bits).IsNotNull();
     _val = bits.GetIntFromBitArray();
 }
 /// <summary>
 /// tests equivalence by converting to int and comparing
 /// </summary>
 /// <param name="ba1"></param>
 /// <param name="ba2"></param>
 /// <returns></returns>
 public static bool AreEquivalent_IntCompare(this BitArray ba1, BitArray ba2)
 {
     return ba1.GetIntFromBitArray().Equals(ba2.GetIntFromBitArray());
 }
 public NaturalBitVectorHasBits(BitArray bits)
 {
     Condition.Requires(bits).IsNotNull();
     _bv = new BitVector32(bits.GetIntFromBitArray());
 }