C# Double Epsilon
Description
Double Epsilon
represents the smallest positive Double
value that is greater than zero. This field is constant.
Syntax
Double.Epsilon
has the following syntax.
public const double Epsilon
Example
The following code shows how to use Double.Epsilon
field.
/*from w ww . j av a 2 s . c o m*/
using System;
public class Example
{
public static void Main()
{
double[] values = { 0, Double.Epsilon, Double.Epsilon * .5 };
for (int ctr = 0; ctr <= values.Length - 2; ctr++)
{
for (int ctr2 = ctr + 1; ctr2 <= values.Length - 1; ctr2++)
{
Console.WriteLine("{0:r} = {1:r}: {2}",
values[ctr], values[ctr2],
values[ctr].Equals(values[ctr2]));
}
}
}
}
The code above generates the following result.