public static Tryte operator +(Tryte t1, Tryte t2) { Tryte tryte = new Tryte(); Trit carry = Trit.Neu; for (int i = 0; i < NUMBER_OF_TRITS; i++) { tryte[i] = t1[i].Add(t2[i], ref carry); while (carry != Trit.Neu) { if (++i == NUMBER_OF_TRITS) { break; } Trit tc = Trit.Neu; tryte[i] = carry.Add(t1[i], ref tc).Add(t2[i], ref carry); if (carry == Trit.Neu) { carry = tc; } else if (tc != Trit.Neu) { carry = carry.Add(tc, ref tc); } } } return(tryte); }
protected void Output(int pin, Trit inputStateA, Trit inputStateB, Trit inputStateCarry, object sender = null) { Trit sum = inputStateA.Add(inputStateB, ref inputStateCarry); InvokeOutput(pin, sum, sender ?? this); CarryOuts[pin]?.Invoke(sender ?? this, inputStateCarry); }