public void AddBinaryReturnBinary(int[] argInts, int result) { var output = new NumberWithBase(0, 2); output = argInts.Aggregate(output, (current, argInt) => current + new NumberWithBase(argInt, 2)); Assert.AreEqual(result, output.Value); }
private static void Evaluate(int input, int expected, int sourceBase, int targetBase) { var test = new NumberWithBase(input, sourceBase); test.ChangeBase(targetBase); Assert.AreEqual(expected, test.Value); }
public static NumberWithBase operator +(NumberWithBase n1, NumberWithBase n2) { if (n2.BaseValue != n1.BaseValue) { n2.ChangeBase(n1.BaseValue); } var numToAdd = new NumberWithBase(n1.Value + n2.Value, n1.BaseValue); numToAdd._checkBase(); return(numToAdd); }