示例#1
0
        /// <summary>
        /// Multiplies
        /// </summary>
        /// <param name="one">operand one</param>
        /// <param name="two">operand two</param>
        /// <returns></returns>
        public string Multiply(ComplexData one, ComplexData two)
        {
            realNumberResult = (one.getRealNumber() * two.getRealNumber()) + ((two.getComplexNumber() * one.getComplexNumber()) * -1);
            imagNumberResult = (one.getComplexNumber() * two.getRealNumber()) + (two.getComplexNumber() * one.getRealNumber());

            result = realNumberResult + "" + imagNumberResult.ToString("+0.###;-#.###") + "i";

            return(result);
        }
示例#2
0
        /// <summary>
        /// Adds the two operands together
        /// </summary>
        /// <param name="one">operand one</param>
        /// <param name="two">operand two</param>
        /// <returns></returns>
        public string Add(ComplexData one, ComplexData two)
        {
            realNumberResult = one.getRealNumber() + two.getRealNumber();
            imagNumberResult = one.getComplexNumber() + two.getComplexNumber();

            result = realNumberResult + "" + imagNumberResult.ToString("+0.###;-#.###") + "i";
            return(result);
        }
示例#3
0
        /// <summary>
        /// Divides
        /// </summary>
        /// <param name="one">operand one</param>
        /// <param name="two">operand two</param>
        /// <returns></returns>
        public string Divide(ComplexData one, ComplexData two)
        {
            ComplexData conjugate   = new ComplexData();
            string      numerator   = "";
            string      denominator = "";

            conjugate.setComplexNumber(two.getComplexNumber() * -1);
            conjugate.setRealNumber(two.getRealNumber());
            numerator   = Multiply(one, conjugate);
            denominator = Multiply(two, conjugate);

            result = numerator + "\n" + "-----------\n" + denominator;
            return(result);
        }