DoubleDouble Structure |
Namespace: Meta.Numerics.Extended
The DoubleDouble type exposes the following members.
Name | Description | |
---|---|---|
DoubleDouble |
Initializes a new double double number from the given string.
|
Name | Description | |
---|---|---|
Abs |
Computes the absolute value of a double double number.
| |
Compare |
Compares two values.
| |
CompareTo |
Compares the current value to another.
| |
Cos |
Computes the cosine of a double double value.
| |
Equals(Object) |
Determines whether the current value is equal to another object.
(Overrides ValueTypeEquals(Object).) | |
Equals(DoubleDouble) |
Determines whether the current value is equal to another value.
| |
Equals(DoubleDouble, DoubleDouble) |
Determines whether two double double values are equal.
| |
Exp |
Computes the exponential of a double double value.
| |
GetHashCode |
Gets a hash code for the current value.
(Overrides ValueTypeGetHashCode.) | |
GetRandomValue |
Gets a random double double value.
| |
GetType | Gets the Type of the current instance. (Inherited from Object.) | |
IsNaN |
Determines whether a double double value is not-a-number.
| |
Log |
Computes the natural logarithm of a double double value.
| |
Parse |
Parses a string representation of a double double value.
| |
Pow |
Raises a double double number to an integer power.
| |
Sin |
Computes the sine of a double double value.
| |
Sqrt |
Computes the square root of a double double value.
| |
ToString |
Produces a string representation of the double double value.
(Overrides ValueTypeToString.) | |
TryParse |
Attempts to parse a string representation of a double double value.
|
Name | Description | |
---|---|---|
Addition |
Computes the sum of two double double numbers.
| |
Division |
Computes the quotient of two double double numbers.
| |
Equality |
Determines whether two double double values are equal.
| |
(DoubleDouble to Double) |
Converts a double double value to a double value.
| |
GreaterThan |
Determines whether the first value is greater than the second value.
| |
GreaterThanOrEqual |
Determines whether the first value is greater than or equal to the second value.
| |
(Double to DoubleDouble) |
Converts a double value to a double double value.
| |
Inequality |
Determines whether two double double values are unequal.
| |
LessThan |
Determines whether the first value is less than the second value.
| |
LessThanOrEqual |
Determines whether the first value is less than or equal to the second value.
| |
Multiply |
Computes the product of two double double numbers.
| |
Subtraction |
Computes the difference of two double double numbers.
| |
UnaryNegation |
Negates a double double number.
|
Name | Description | |
---|---|---|
E |
The double double value of the base of natural logarithms.
| |
NaN |
The double double not-a-number value.
| |
NegativeInfinity |
The double double negative infinite value.
| |
One |
The double double number one.
| |
Pi |
The double double value of pi.
| |
PositiveInfinity |
The double double positive infinite value.
| |
Zero |
The double double number zero.
|
The DoubleDouble structure uses two Double values to achieve twice the precision with which a floating point number can be stored and manipulated as compared to to the Double structure, approximately 31 decimal digits.
Of all the extended precision floating point systems, double double is the fastest when implemented in software. A typical floating point operation using DoubleDoubles is just 3-4 times slower than using Doubles.
To instantiate a DoubleDouble, you can use TryParse(String, DoubleDouble), or Parse(String), or the constructor DoubleDouble(String) to parse the text representation of the decimal value you want. If the value you want can be represented as a Double or Int32 or other built in numeric type, you can cast that value to a DoubleDouble.
When casting a Double to a DoubleDouble, there is a gotcha that you must be careful to avoid. Suppose you write DoubleDouble x = 0.2 or DoubleDouble x = 1.0 / 5.0. You might think that this produces the DoubleDouble representation of 1/5, but you would be wrong. The problem is that the compiler intreprets 0.2 or 1.0/5.0 as Doubles, and 1/5th is not exactly representable as a double, since it is not a rational number with a power-of-two denominator. Double's best attempt at 1/5th is 3602879701896397 X 2^-54 = 0.20000000000000001110223024625157..., which is accurate to 16 decimal digits, but not to 32. Therefore when it is cast to a DoubleDouble it is much farther away from 1/5th than DoubleDouble can achieve. To obtain 1/5th to the accuracy of a DoubleDouble, you must write DoubleDouble x = new DoubleDouble("0.2") or DoubleDouble x = (DoubleDouble) 1 / 5. (The latter works because 1 and 5 are exactly representable and the division is performed as DoubleDouble division. All integers in range, indeed all rational numbers with in-range numerators and power-of-two denominators, are exactly representable. So, for example, DoubleDouble x = 0.25does work as expected, because 1/4 is exactly representable. But to avoid the gotcha it's best to simply train yourself to avoid assigning DoubleDouble variables from factional Double values.)
Many of the mathematical functions which are implemented for Double arguments by static methods of the Math class are implemented for DoubleDouble arguments by static methods of the DoubleDouble type itself, for example Sqrt(DoubleDouble) and Log(DoubleDouble). Some of the advanced functions which are implemented for Double arguments by static methods of the AdvancedMath class are implemented for DoubleDouble arguments by static methods of the AdvancedDoubleDoubleMath class.
You may wonder why DoubleDouble is not simply named "Quad". The reason is that "Quad" would propertly refer to an implementation of the IEEE 754 quadruple-precision binary floating point format, which would have not only the extended presion of DoubleDouble, but also an extended range (up to 104932).