Beispiel #1
0
        public static BitTwiddler FromBytes(IEnumerator <sbyte> bytes, int length)
        {
            int byteCount = CorrectByteCount(length);

            var result = BitTwiddler.WithByteCount(byteCount);

            for (int i = 0; i < byteCount; i++)
            {
                bytes.MoveNext();

                result = result.SetSignedByte(bytes.Current);
            }

            return(result);
        }
Beispiel #2
0
        public static BitTwiddler FromBytes(IEnumerator <byte> bytes, int length)
        {
            if (length < 0)
            {
                throw new ArgumentOutOfRangeException("length");
            }

            int byteCount = Math.Min(length, MaxByteCount);

            var result = BitTwiddler.WithByteCount(byteCount);

            for (int i = 0; i < byteCount; i++)
            {
                bytes.MoveNext();

                result = result.SetByte(bytes.Current);
            }

            return(result);
        }
Beispiel #3
0
        public static BitTwiddler FromBytes(sbyte[] bytes, int index, int length)
        {
            if (index < 0 || index > bytes.Length)
            {
                throw new ArgumentOutOfRangeException("index");
            }
            if (length < 0 || index + length > bytes.Length)
            {
                throw new ArgumentOutOfRangeException("length");
            }

            int byteCount = Math.Min(length, MaxByteCount);

            var result = BitTwiddler.WithByteCount(byteCount);

            for (int i = 0; i < byteCount; i++)
            {
                result = result.SetSignedByte(bytes[i], i);
            }

            return(result);
        }
Beispiel #4
0
 public BitTwiddler Xor(BitTwiddler value) => this ^ value;
Beispiel #5
0
 public BitTwiddler Or(BitTwiddler value) => this | value;
Beispiel #6
0
 // Logical
 public BitTwiddler And(BitTwiddler value) => this & value;
Beispiel #7
0
 public BitTwiddler Modulus(BitTwiddler value) => this % value;
Beispiel #8
0
 public BitTwiddler DivideBy(BitTwiddler value) => this / value;
Beispiel #9
0
 public BitTwiddler MultiplyBy(BitTwiddler value) => this * value;
Beispiel #10
0
 public BitTwiddler Subtract(BitTwiddler value) => this - value;
Beispiel #11
0
 public BitTwiddler Add(BitTwiddler value) => this + value;