Information
The topic you requested is included in another documentation set. For convenience, it's displayed below. Choose Switch to see the topic in its original location.

Single.Epsilon Field

Represents the smallest positive Single greater than zero. This field is constant.

[Visual Basic]
Public Const Epsilon As Single
[C#]
public const float Epsilon;
[C++]
public: const float Epsilon;
[JScript]
public var Epsilon : float;

Remarks

The value of this constant is 1.4e-45.

Two apparently equivalent floating point numbers might not compare equal because of differences in their least significant digits. For example, the C# expression, (float)1/3 == (float)0.33333, does not compare equal because the division operation on the left-hand side has maximum precision while the constant on the right-hand side is only precise to the visible digits.

Instead, determine if the two sides of a comparison are close enough to equal for your purposes by comparing whether the absolute value of the difference between the left and right-hand sides is less than Epsilon.

Example

[Visual Basic, C#, C++] The following sample displays the Epsilon constant.

[Visual Basic] 
Console.WriteLine("Epsilon, or the permittivity of a vacuum, has value " + Single.Epsilon.ToString())

[C#] 
Console.WriteLine("Epsilon, or the permittivity of a vacuum, has value {0}", Single.Epsilon.ToString());

[C++] 
Console::WriteLine(S"Epsilon, or the permittivity of a vacuum, has value {0}", __box(Single::Epsilon));

[JScript] No example is available for JScript. To view a Visual Basic, C#, or C++ example, click the Language Filter button Language Filter in the upper-left corner of the page.

Requirements

Platforms: Windows 98, Windows NT 4.0, Windows Millennium Edition, Windows 2000, Windows XP Home Edition, Windows XP Professional, Windows Server 2003 family, .NET Compact Framework, Common Language Infrastructure (CLI) Standard

See Also

Single Structure | Single Members | System Namespace

Show:
© 2014 Microsoft