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); }
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); }
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); }
public BitTwiddler Xor(BitTwiddler value) => this ^ value;
public BitTwiddler Or(BitTwiddler value) => this | value;
// Logical public BitTwiddler And(BitTwiddler value) => this & value;
public BitTwiddler Modulus(BitTwiddler value) => this % value;
public BitTwiddler DivideBy(BitTwiddler value) => this / value;
public BitTwiddler MultiplyBy(BitTwiddler value) => this * value;
public BitTwiddler Subtract(BitTwiddler value) => this - value;
public BitTwiddler Add(BitTwiddler value) => this + value;