Was this page helpful?
Your feedback about this content is important. Let us know what you think.
Additional feedback?
1500 characters remaining
Export (0) Print
Expand All

Double.Equals Method (Double)

Note: This method is new in the .NET Framework version 2.0.

Returns a value indicating whether this instance and a specified Double object represent the same value.

Namespace: System
Assembly: mscorlib (in mscorlib.dll)

public bool Equals (
	double obj
)
public final boolean Equals (
	double obj
)
public final function Equals (
	obj : double
) : boolean

Parameters

obj

A Double object to compare to this instance.

Return Value

true if obj is equal to this instance; otherwise, false.

This method implements the System.IEquatable interface, and performs slightly better than Equals because it does not have to convert the obj parameter to an object.

Widening Conversions

Depending on your programming language, it might be possible to code a Equals method where the parameter type has fewer bits (is narrower) than the instance type. This is possible because some programming languages perform an implicit widening conversion that represents the parameter as a type with as many bits as the instance.

For example, suppose the instance type is Double and the parameter type is Int32. The Microsoft C# compiler generates instructions to represent the value of the parameter as a Double object, then generates a Double.Equals(Double) method that compares the values of the instance and the widened representation of the parameter.

Consult your programming language's documentation to determine if its compiler performs implicit widening conversions of numeric types. For more information, see the Type Conversion Tables topic.

Precision in Comparisons

The precision of floating-point numbers beyond the documented precision is specific to the implementation and version of the .NET Framework. Consequently, a comparison of two particular numbers might change between versions of the .NET Framework because the precision of the numbers' internal representation might change.

Windows 98, Windows 2000 SP4, Windows CE, Windows Millennium Edition, Windows Mobile for Pocket PC, Windows Mobile for Smartphone, Windows Server 2003, Windows XP Media Center Edition, Windows XP Professional x64 Edition, Windows XP SP2, Windows XP Starter Edition

The .NET Framework does not support all versions of every platform. For a list of the supported versions, see System Requirements.

.NET Framework

Supported in: 2.0

.NET Compact Framework

Supported in: 2.0

Community Additions

ADD
Show:
© 2015 Microsoft