Click or drag to resize

DoubleDouble Structure

Represents a floating point number with quadruple precision.

Namespace:  Meta.Numerics.Extended
Assembly:  Meta.Numerics (in Meta.Numerics.dll) Version: 4.1.4
Syntax
public struct DoubleDouble : IEquatable<DoubleDouble>, 
	IComparable<DoubleDouble>

The DoubleDouble type exposes the following members.

Constructors
  NameDescription
Public methodDoubleDouble
Initializes a new double double number from the given string.
Top
Methods
  NameDescription
Public methodStatic memberAbs
Computes the absolute value of a double double number.
Public methodStatic memberCompare
Compares two values.
Public methodCompareTo
Compares the current value to another.
Public methodStatic memberCos
Computes the cosine of a double double value.
Public methodEquals(Object)
Determines whether the current value is equal to another object.
(Overrides ValueTypeEquals(Object).)
Public methodEquals(DoubleDouble)
Determines whether the current value is equal to another value.
Public methodStatic memberEquals(DoubleDouble, DoubleDouble)
Determines whether two double double values are equal.
Public methodStatic memberExp
Computes the exponential of a double double value.
Public methodGetHashCode
Gets a hash code for the current value.
(Overrides ValueTypeGetHashCode.)
Public methodStatic memberGetRandomValue
Gets a random double double value.
Public methodGetType
Gets the Type of the current instance.
(Inherited from Object.)
Public methodStatic memberIsNaN
Determines whether a double double value is not-a-number.
Public methodStatic memberLog
Computes the natural logarithm of a double double value.
Public methodStatic memberParse
Parses a string representation of a double double value.
Public methodStatic memberPow
Raises a double double number to an integer power.
Public methodStatic memberSin
Computes the sine of a double double value.
Public methodStatic memberSqrt
Computes the square root of a double double value.
Public methodToString
Produces a string representation of the double double value.
(Overrides ValueTypeToString.)
Public methodStatic memberTryParse
Attempts to parse a string representation of a double double value.
Top
Operators
  NameDescription
Public operatorStatic memberAddition
Computes the sum of two double double numbers.
Public operatorStatic memberDivision
Computes the quotient of two double double numbers.
Public operatorStatic memberEquality
Determines whether two double double values are equal.
Public operatorStatic member(DoubleDouble to Double)
Converts a double double value to a double value.
Public operatorStatic memberGreaterThan
Determines whether the first value is greater than the second value.
Public operatorStatic memberGreaterThanOrEqual
Determines whether the first value is greater than or equal to the second value.
Public operatorStatic member(Double to DoubleDouble)
Converts a double value to a double double value.
Public operatorStatic memberInequality
Determines whether two double double values are unequal.
Public operatorStatic memberLessThan
Determines whether the first value is less than the second value.
Public operatorStatic memberLessThanOrEqual
Determines whether the first value is less than or equal to the second value.
Public operatorStatic memberMultiply
Computes the product of two double double numbers.
Public operatorStatic memberSubtraction
Computes the difference of two double double numbers.
Public operatorStatic memberUnaryNegation
Negates a double double number.
Top
Fields
  NameDescription
Public fieldStatic memberE
The double double value of the base of natural logarithms.
Public fieldStatic memberNaN
The double double not-a-number value.
Public fieldStatic memberNegativeInfinity
The double double negative infinite value.
Public fieldStatic memberOne
The double double number one.
Public fieldStatic memberPi
The double double value of pi.
Public fieldStatic memberPositiveInfinity
The double double positive infinite value.
Public fieldStatic memberZero
The double double number zero.
Top
Remarks

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).

See Also