Struct double
Represents a double-precision floating-point number.
Inherited Members
Namespace: System
Assembly: mscorlib.dll
Syntax
public double
Fields
Epsilon
Represents the smallest positive Double value that is greater than zero. This field is constant.
Declaration
public const double Epsilon = 5E-324
Field Value
Type | Description |
---|---|
double |
Remarks
The value of this constant is 4.94065645841247e-324.
MaxValue
Represents the largest possible value of a Double. This field is constant.
Declaration
public const double MaxValue = 1.7976931348623157E+308
Field Value
Type | Description |
---|---|
double |
Remarks
The value of this constant is positive 1.7976931348623157E+308.
MinValue
Represents the smallest possible value of a Double. This field is constant.
Declaration
public const double MinValue = -1.7976931348623157E+308
Field Value
Type | Description |
---|---|
double |
Remarks
The value of this constant is negative 1.7976931348623157E+308.
NaN
Represents a value that is not a number (NaN). This field is constant.
Declaration
public const double NaN = NaN
Field Value
Type | Description |
---|---|
double |
NegativeInfinity
Represents negative infinity. This field is constant.
Declaration
public const double NegativeInfinity = -Infinity
Field Value
Type | Description |
---|---|
double |
PositiveInfinity
Represents positive infinity. This field is constant.
Declaration
public const double PositiveInfinity = Infinity
Field Value
Type | Description |
---|---|
double |
Methods
CompareTo(double)
Compares this instance to a specified double-precision floating-point number and returns an integer that indicates whether the value of this instance is less than, equal to, or greater than the value of the specified double-precision floating-point number.
Declaration
public int CompareTo(double value)
Parameters
Type | Name | Description |
---|---|---|
double | value | A double-precision floating-point number to compare. |
Returns
Type | Description |
---|---|
int | A signed number indicating the relative values of this instance and value. Less than zero: This instance is less than value. -or- This instance is not a number (NaN) and value is a number. Zero: This instance is equal to value. -or- Both this instance and value are not a number (NaN), PositiveInfinity, or NegativeInfinity. Greater than zero: This instance is greater than value. -or- This instance is a number and value is not a number (NaN). |
IsInfinity(double)
Returns a value indicating whether the specified number evaluates to negative or positive infinity
Declaration
public static bool IsInfinity(double d)
Parameters
Type | Name | Description |
---|---|---|
double | d | A double-precision floating-point number. |
Returns
Type | Description |
---|---|
bool | true if d evaluates to PositiveInfinity or NegativeInfinity; otherwise, false. |
IsNaN(double)
Returns a value that indicates whether the specified value is not a number (NaN).
Declaration
public static bool IsNaN(double d)
Parameters
Type | Name | Description |
---|---|---|
double | d | A double-precision floating-point number. |
Returns
Type | Description |
---|---|
bool | true if d evaluates to NaN; otherwise, false. |
IsNegativeInfinity(double)
Returns a value indicating whether the specified number evaluates to negative infinity.
Declaration
public static bool IsNegativeInfinity(double d)
Parameters
Type | Name | Description |
---|---|---|
double | d | A double-precision floating-point number. |
Returns
Type | Description |
---|---|
bool | true if d evaluates to NegativeInfinity; otherwise, false. |
IsPositiveInfinity(double)
Returns a value indicating whether the specified number evaluates to positive infinity.
Declaration
public static bool IsPositiveInfinity(double d)
Parameters
Type | Name | Description |
---|---|---|
double | d | A double-precision floating-point number. |
Returns
Type | Description |
---|---|
bool | true if d evaluates to PositiveInfinity; otherwise, false. |
Parse(string)
Converts the string representation of a number to its double-precision floating-point number equivalent.
Declaration
public static double Parse(string s)
Parameters
Type | Name | Description |
---|---|---|
string | s | A string that contains a number to convert. |
Returns
Type | Description |
---|---|
double | A double-precision floating-point number that is equivalent to the numeric value or symbol specified in s. |
Exceptions
Type | Condition |
---|---|
ArgumentNullException |
|
ToString()
Converts the numeric value of this instance to its equivalent string representation.
Declaration
public override string ToString()
Returns
Type | Description |
---|---|
string | The string representation of the value of this instance. |
Overrides
ToString(string)
Converts the numeric value of this instance to its equivalent string representation, using the specified format.
Declaration
public string ToString(string format)
Parameters
Type | Name | Description |
---|---|---|
string | format | A numeric format string. |
Returns
Type | Description |
---|---|
string | The string representation of the value of this instance as specified by format. |
TryParse(string, out double)
Converts the string representation of a number to its double-precision floating-point number equivalent. A return value indicates whether the conversion succeeded or failed.
Declaration
public static bool TryParse(string s, out double result)
Parameters
Type | Name | Description |
---|---|---|
string | s | A string containing a number to convert. |
double | result | When this method returns, contains the double-precision floating-point number equivalent of the |
Returns
Type | Description |
---|---|
bool | true if |
Remarks
Values that are too large to represent are rounded to PositiveInfinity or NegativeInfinity as required by the IEEE 754 specification.
This overload differs from the Parse(string)(String) method by returning a bool value that indicates whether the parse operation succeeded instead of returning the parsed numeric value. It eliminates the need to use exception handling to test for a FormatException in the event that s
is invalid and cannot be successfully parsed.