Complex.Abs(Complex) Method
Important
Some information relates to prerelease product that may be substantially modified before it’s released. Microsoft makes no warranties, express or implied, with respect to the information provided here.
Gets the absolute value (or magnitude) of a complex number.
public:
static double Abs(System::Numerics::Complex value);
public static double Abs(System.Numerics.Complex value);
static member Abs : System.Numerics.Complex -> double
Public Shared Function Abs (value As Complex) As Double
- value
- Complex
A complex number.
The absolute value of value
.
The following example calculates the absolute value of a complex number and demonstrates that it is equivalent to the value of the Magnitude property.
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));
}
}
// The example displays the following output:
// |(2, 3)| = 3.61
// Equal to Magnitude: True
open System.Numerics
let complex1 = Complex(2., 3.)
printfn $"|{complex1}| = {Complex.Abs complex1:N2}"
printfn $"Equal to Magnitude: {Complex.Abs(complex1).Equals complex1.Magnitude}"
// The example displays the following output:
// |(2, 3)| = 3.61
// Equal to Magnitude: True
The absolute value of a complex number is equivalent to its Magnitude property. The absolute value of a complex number a + bi
is calculated as follows:
- If
b = 0
, the result isa
. - If
a > b
, the result is . - If
b > a
, the result is .
If the calculation of the absolute value results in an overflow, the method returns either Double.PositiveInfinity or Double.NegativeInfinity. If either the Real or Imaginary property is Double.NaN and the other property is neither Double.PositiveInfinity nor Double.NegativeInfinity, the method returns Double.NaN.
Product | Versions |
---|---|
.NET | Core 1.0, Core 1.1, Core 2.0, Core 2.1, Core 2.2, Core 3.0, Core 3.1, 5, 6, 7, 8, 9, 10 |
.NET Framework | 4.0, 4.5, 4.5.1, 4.5.2, 4.6, 4.6.1, 4.6.2, 4.7, 4.7.1, 4.7.2, 4.8, 4.8.1 |
.NET Standard | 1.1, 1.2, 1.3, 1.4, 1.6, 2.0, 2.1 |
UWP | 10.0 |
.NET feedback
.NET is an open source project. Select a link to provide feedback: