Gets the absolute value (or magnitude) of a complex number. : Complex « Data Types « C# / C Sharp






Gets the absolute value (or magnitude) of a complex number.

 


using System;
using System.Numerics;

public class Example
{
   public static void Main()
   {
      Complex complex1 = new Complex(2.0, 3.0);
      Console.WriteLine("|{0}| = {1:N2}", complex1, Complex.Abs(complex1));
      Console.WriteLine("Equal to Magnitude: {0}", 
                        Complex.Abs(complex1).Equals(complex1.Magnitude)); 
   }
}

   
  








Related examples in the same category

1.A Complex Number ClassA Complex Number Class
2.Complex number class
3.Class to do math on complex numbers.
4.Initializes a new instance of the Complex structure using the specified real and imaginary values.
5.Complex Structure represents a complex number.
6.Assign a Double to a complex number
7.Cast a Decimal to a complex number
8.Assign the return value of a method to a Complex variable
9.Assign the value returned by an operator to a Complex variable
10.Instantiate a complex number from its polar coordinates
11.Complex.Exp
12.Complex.Sqrt
13.Divide and multiply
14.Returns the angle that is the arc cosine of the specified complex number.
15.Adds two complex numbers and returns the result.
16.Adds two complex numbers.
17.Returns the angle that is the arc sine of the specified complex number.
18.Returns the angle that is the arc tangent of the specified complex number.
19.Computes the conjugate of a complex number and returns the result.
20.Divides one complex number by another and returns the result.
21.Returns a value that indicates whether the current instance and a specified complex number have the same value.
22.Returns e raised to the power specified by a complex number.
23.Creates a complex number from a point's polar coordinates.
24.Gets the imaginary component of the current Complex object.
25.Returns a new Complex instance with a real number equal to zero and an imaginary number equal to one.
26.Returns the product of two complex numbers.
27.Returns the additive inverse of a specified complex number.
28.Returns a new Complex instance with a real number equal to one and an imaginary number equal to zero.
29.Returns a specified complex number raised to a power specified by a double-precision floating-point number.
30.Returns the multiplicative inverse of a complex number.
31.Subtracts one complex number from another and returns the result.
32.Converts current complex number to string in Cartesian form by using the specified culture-specific formatting information.
33.Converts current complex number to string in Cartesian form by using the specified format for its real and imaginary parts.
34.Converts complex number to string representation in Cartesian form by using the specified format and culture-specific format information for its real and imaginary parts.
35.Converts the value of the current complex number to its equivalent string representation in Cartesian form.
36.Returns a new Complex instance with a real number equal to zero and an imaginary number equal to zero.