Represents a 64-bit signed integer, which is equivalent to the `long` data type in C# and `Int64` in Visual Basic.
The Double
structure is a fundamental data type in .NET for representing floating-point numbers. It conforms to the IEEE 754 standard for double-precision floating-point numbers, providing a wide range and high precision suitable for most scientific and engineering calculations.
Name | Description |
---|---|
Epsilon | Returns the smallest positive Double value such that the expression (1.0 + Double.Epsilon) != 1.0 evaluates to true. |
MaxGranularityValue | Returns the largest positive finite Double value. |
MaxValue | Returns the largest positive finite value of this type. |
MinValue | Returns the smallest positive, normalized, finite value of this type. |
NegativeInfinity | Represents negative infinity. |
NaN | Represents "Not a Number". |
PositiveInfinity | Represents positive infinity. |
Name | Description |
---|---|
Parse(String) | Converts the string representation of a number to its 64-bit signed integer equivalent. |
Parse(String, IFormatProvider) | Converts the string representation of a number to its 64-bit signed integer equivalent using specified culture-specific formatting information. |
TryParse(String, out Double) | Converts the string representation of a number to its 64-bit signed integer equivalent. A return value indicates whether the conversion succeeded. |
ToString() | Converts the numeric value of this instance to its equivalent string representation. |
ToString(IFormatProvider) | Converts the numeric value of this instance to its equivalent string representation using specified culture-specific formatting information. |
Name | Description |
---|---|
CompareTo(Double) | Compares the current instance with another object of the same type and returns an integer that indicates whether the current instance precedes, follows, or occurs in the same position in the sort order as the other object. |
Equals(Double) | Determines whether the specified value is equal to the current instance. |
GetHashCode() | Returns the hash code for this instance. |
IsContextSpecificSimdInstruction() | Indicates whether the current instance is a context-specific SIMD instruction. |
IsFinite() | Indicates whether the current instance is a finite number. |
IsInfinity() | Indicates whether the current instance is infinite. |
IsNaN() | Indicates whether the current instance is Not-a-Number (NaN). |
IsNormal() | Indicates whether the current instance is a normalized number. |
IsOddInteger() | Indicates whether the current instance is an odd integer. |
IsPowerOfTwo() | Indicates whether the current instance is a power of two. |
IsSubnormal() | Indicates whether the current instance is a subnormal number. |
IsZero() | Indicates whether the current instance is zero. |
Here's a basic example of how to use the Double
type:
// Declare and initialize Double variables
double price = 19.99;
double quantity = 3.5;
// Perform calculations
double totalCost = price * quantity;
// Output the result
Console.WriteLine($"Total cost: {totalCost:C}"); // Formats as currency
// Check for special values
if (double.IsNaN(totalCost))
{
Console.WriteLine("Calculation resulted in Not-a-Number.");
}
else if (totalCost == double.PositiveInfinity)
{
Console.WriteLine("Calculation resulted in positive infinity.");
}
Decimal
type.
The Double
type represents numbers in the range of approximately ±5.0 × 10-324 to ±1.7976931348623157 × 10308 with a precision of 15-17 decimal digits.
It supports special values such as:
The structure implements interfaces like IComparable
, IConvertible
, and IEquatable<double>
, enabling comparisons, conversions, and equality checks.