/// <summary> /// Does the math operation. /// </summary> private void do_math_operation() { /// <sumamry> Variable lastOperator stores last operation which will be performed </summary> switch (lastOperator) { case "+": operand1 = Math.Add(operand1, dispString_to_numb(display.Text)); break; case "-": operand1 = Math.Add(operand1, -(dispString_to_numb(display.Text))); break; case "*": operand1 = Math.Mul(operand1, dispString_to_numb(display.Text)); break; case "/": operand1 = Math.Div(operand1, dispString_to_numb(display.Text)); break; case "power": operand1 = Math.Pow(operand1, dispString_to_numb(display.Text)); break; case "root": operand1 = Math.Root(operand1, dispString_to_numb(display.Text)); break; case "log": operand1 = Math.Log(dispString_to_numb(display.Text), operand1); break; default: break; } }
public void MulTest() { Assert.AreEqual(0, math.Mul(0, 0)); Assert.AreEqual(30, math.Mul(5, 6)); Assert.AreEqual(10, math.Mul(-2, -5)); Assert.AreEqual(-10, math.Mul(2, -5)); Assert.AreEqual(-10, math.Mul(-2, 5)); Assert.AreEqual(0, math.Mul(3516, 0)); Assert.AreEqual(0, math.Mul(0, 3516)); Assert.AreEqual(0.25, math.Mul(0.5, 0.5), Exactness); Assert.AreEqual(-0.25, math.Mul(-0.5, 0.5), Exactness); Assert.AreEqual(0.23545135, math.Mul(1, 0.23545135), Exactness); Assert.AreEqual(200000000, math.Mul(2, 100000000)); Assert.AreEqual(200000000, math.Mul(-2, -100000000)); }