public (bool Sum, bool CarryOut) Add(bool a, bool b, bool carryIn) { var aXorB = _xOr.Apply(a, b); var sum = _xOr.Apply(aXorB, carryIn); var aAndB = _and.Apply(a, b); var aXorBAndCarryIn = _and.Apply(aXorB, carryIn); var carryOut = _or.Apply(aAndB, aXorBAndCarryIn); return(sum, carryOut); }
public (bool equal, bool ALarger, bool output) AreEqual(bool a, bool b, bool aboveBitIsEqual, bool aboveBitALarger) { var unequal = _xOr.Apply(a, b); var equal = _not.Apply(unequal); var equalAndAboveBitEqual = _and.Apply(equal, aboveBitIsEqual); var aLarger = _and.Apply(aboveBitIsEqual, unequal, a); var aLargerOrAboveALarger = _or.Apply(aLarger, aboveBitALarger); return(equalAndAboveBitEqual, aLargerOrAboveALarger, unequal); }
public IByte Apply(params IByte[] input) { var groups = new List <List <bool> >(); for (var i = 0; i < input[0].Count; i++) { var tempList = input.Select(t => t[i]).ToList(); groups.Add(tempList); } var result = groups.Select(s => _xOr.Apply(s.ToArray())).ToArray(); return(_byteFactory.Create(result)); }