public void MultiplicationTest() { ComplementCode cc1 = new ComplementCode(6, "00101"); ComplementCode cc2 = new ComplementCode(6, "00011"); cc1 = cc1 * (-cc2); Assert.AreEqual("110001", cc1.ToString()); }
public void CopyTest() { ComplementCode cc1 = new ComplementCode(5, "11111"); ComplementCode cc2 = new ComplementCode(cc1); Assert.IsTrue(cc1 == cc2); Assert.IsFalse(cc1.Equals(cc2)); }
public void DivideTestOne() { //8 / 4 = 2 ComplementCode first = new ComplementCode(5, "1000"); ComplementCode second = new ComplementCode(5, "100"); first = first / second; Assert.AreEqual("00010", first.ToString()); }
public void DivideTestTwo() { //-5 / -5 = 1 ComplementCode A = new ComplementCode(5, "101"); ComplementCode B = new ComplementCode(5, "101"); A = -A / -B; Assert.AreEqual("00001", A.ToString()); }
public void EqualTest() { ComplementCode cc1 = new ComplementCode(5, "110"); ComplementCode cc2 = cc1; ComplementCode cc3 = new ComplementCode(5, "110"); Assert.IsTrue(cc1.Equals(cc2)); Assert.IsFalse(cc1.Equals(cc3)); Assert.IsTrue(cc1 == cc3); }
public void AddTest() { ComplementCode cc1 = new ComplementCode(5, "11111"); ComplementCode cc2 = new ComplementCode(5, "1"); ComplementCode cc3 = new ComplementCode(5); cc3 = cc1 + cc2; Assert.AreEqual("00000", cc3.ToString()); }
public void ShiftTest() { ComplementCode cc1 = new ComplementCode(5, "10110"); cc1 >>= 1; Assert.AreEqual("01011", cc1.ToString()); cc1 >>= 3; Assert.AreEqual("00001", cc1.ToString()); }
public void AdditionTestTwo() { // 5 + (-5) = 0 ComplementCode first = new ComplementCode(5, "101"); ComplementCode second = new ComplementCode(5, "101"); first = first + -second; Assert.AreEqual("00000", first.ToString()); }
public void ShiftTest2() { ComplementCode cc1 = new ComplementCode(5, "10110"); cc1 <<= 1; Assert.AreEqual("01100", cc1.ToString()); cc1 <<= 2; Assert.AreEqual("10000", cc1.ToString()); }
public void MultiplyTest() { //257836 * 583864 = 150541158304 ComplementCode first = new ComplementCode(40, "111110111100101100"); ComplementCode second = new ComplementCode(40, "10001110100010111000"); first = first * second; Assert.AreEqual("0010001100001100111100111100011110100000", first.ToString()); }
public void AdditionTest() { //5 + 5 = 10 ComplementCode first = new ComplementCode(5, "101"); ComplementCode second = new ComplementCode(5, "101"); first = first + second; Assert.AreEqual("01010", first.ToString()); }
public void MultiplyTestTwo() { // 5 * -2 = -10 ComplementCode first = new ComplementCode(4, "101"); ComplementCode second = new ComplementCode(4, "10"); first = first * -second; first = -first; Assert.AreEqual("1010", first.ToString()); }
public void MinusTest() { //5 - 7 = (-2) ComplementCode first = new ComplementCode(3, "101"); ComplementCode second = new ComplementCode(3, "111"); first = first - second; first = -first; Assert.AreEqual("010", first.ToString()); }
public void CreatedTest() { ComplementCode cc = new ComplementCode(5, "110"); Assert.AreEqual("00110", cc.ToString()); cc = new ComplementCode("11010"); Assert.AreEqual("11010", cc.ToString()); cc = new ComplementCode(10, "110111"); Assert.AreEqual("0000110111", cc.ToString()); }
public Variable(string value) { string decRepresentationString = Converter.ConvertToDecNumber(new FromSTDConverter(16), value); BigInteger decRepresentationBigInt = BigInteger.Parse(decRepresentationString, System.Globalization.NumberStyles.AllowLeadingSign); decRepresentationBigInt = decRepresentationBigInt % cLM3BitCapacity; ComplementCode complRepresentation = new ComplementCode( Converter.Convert(new FromSTDConverter(10), new ToComplCodeConverter(56), decRepresentationBigInt.ToString())); mValue = complRepresentation; }
public void EqualTest() { // 5 = 5 ComplementCode A = new ComplementCode(5, "101"); ComplementCode B = new ComplementCode(5, "101"); Assert.IsTrue(A == B); //-5 = -5 A = new ComplementCode(5, "101"); A = -A; B = new ComplementCode(5, "101"); B = -B; Assert.IsTrue(A == B); }
public void GreatOrEqualTestTwo() { //3 => 3 ComplementCode A = new ComplementCode(3, "11"); ComplementCode B = new ComplementCode(3, "11"); Assert.IsTrue(A >= B); }
public void GreatOrEqualTestThree() { //2 => -2 ComplementCode A = new ComplementCode(3, "10"); ComplementCode B = new ComplementCode(3, "10"); B = -B; Assert.IsTrue(A >= B); }
public void LessOrEqualTestOne() { // 3 =< 2 ComplementCode A = new ComplementCode(3, "11"); ComplementCode B = new ComplementCode(3, "10"); Assert.IsTrue(B <= A); }
public void LessOrEqualTestTwo() { //3 =< 3 ComplementCode A = new ComplementCode(3, "11"); ComplementCode B = new ComplementCode(3, "11"); Assert.IsTrue(A <= B); }
public void LessOrEqualTestThree() { // 2 =< -2 ComplementCode A = new ComplementCode(3, "10"); ComplementCode B = new ComplementCode(3, "10"); B = -B; Assert.IsTrue(B <= A); }
public void ModuleTest() { ComplementCode cc1 = new ComplementCode(8, "110100"); ComplementCode cc2 = new ComplementCode(8, "111"); cc1 %= cc2; Assert.AreEqual("00000011", cc1.ToString()); }
public void DivideTestThree() { // 10 / -5 = -2 ComplementCode A = new ComplementCode(5, "1010"); ComplementCode B = new ComplementCode(5, "101"); A = A / -B; Assert.AreEqual("11110", A.ToString()); }
public void Exeption() { ComplementCode A = new ComplementCode(-3, "11"); }
public void ExeptionOfBitCapacity() { ComplementCode A = new ComplementCode(3, "11111"); }
public void LessTest() { //2 < 3 ComplementCode A = new ComplementCode(3, "11"); ComplementCode B = new ComplementCode(3, "10"); Assert.IsTrue(B < A); //-2 < 2 A = new ComplementCode(3, "10"); A = -A; B = new ComplementCode(3, "10"); Assert.IsTrue(A < B); }
public void ExeptionNotANumber() { ComplementCode A = new ComplementCode(3, "1a2"); }
public void MinusTest() { ComplementCode cc1 = new ComplementCode(5, "00110"); cc1 = -cc1; Assert.AreEqual("11010", cc1.ToString()); }
public void LessOrEqualTest() { ComplementCode cc1 = new ComplementCode(5, "00100"); ComplementCode cc2 = new ComplementCode(5, "00001"); Assert.IsFalse(cc1 <= cc2); }
public void ExeptionOfBit() { ComplementCode A = new ComplementCode(3, "111"); ComplementCode B = new ComplementCode(7, "1111111"); ComplementCode C = A * B; }