C# Math Abs(Double)
Description
Math Abs(Double)
returns the absolute value of a double-precision
floating-point number.
Syntax
Math.Abs(Double)
has the following syntax.
public static double Abs(
double value
)
Parameters
Math.Abs(Double)
has the following parameters.
value
- A number that is greater than or equal to Double.MinValue, but less than or equal to Double.MaxValue.
Returns
Math.Abs(Double)
method returns A double-precision floating-point number, x, such that 0 d x d Double.MaxValue.
Example
The following example uses the Abs(Double) method to get the absolute value of a number of Double values.
/* w w w. j a va 2s. co m*/
using System;
public class Example
{
public static void Main()
{
double[] doubles = { Double.MaxValue, 16.354e-17, 15.123456, 0,
-19.012345, -15.058e18, Double.MinValue };
foreach (double value in doubles)
Console.WriteLine("Abs({0}) = {1}", value, Math.Abs(value));
}
}
The code above generates the following result.