System.Numerics.Tests.ComplexTests.Divide C# (CSharp) Method

Divide() private method

private Divide ( double realLeft, double imaginaryLeft, double realRight, double imaginaryRight ) : void
realLeft double
imaginaryLeft double
realRight double
imaginaryRight double
return void
        public static void Divide(double realLeft, double imaginaryLeft, double realRight, double imaginaryRight)
        {
            var dividend = new Complex(realLeft, imaginaryLeft);
            var divisor = new Complex(realRight, imaginaryRight);

            Complex expected = dividend * Complex.Conjugate(divisor);
            double expectedReal = expected.Real;
            double expectedImaginary = expected.Imaginary;

            if (!double.IsInfinity(expectedReal))
            {
                expectedReal = expectedReal / (divisor.Magnitude * divisor.Magnitude);
            }
            if (!double.IsInfinity(expectedImaginary))
            {
                expectedImaginary = expectedImaginary / (divisor.Magnitude * divisor.Magnitude);
            }

            // Operator
            Complex result = dividend / divisor;
            VerifyRealImaginaryProperties(result, expectedReal, expectedImaginary);

            // Static method
            result = Complex.Divide(dividend, divisor);
            VerifyRealImaginaryProperties(result, expectedReal, expectedImaginary);
        }
ComplexTests