Search Results for

    Show / Hide Table of Contents

    Struct DD

    Implements extended-precision floating-point numbers which maintain 106 bits (approximately 30 decimal digits) of precision.

    A DoubleDouble uses a representation containing two double-precision values. A number x is represented as a pair of doubles, x.hi and x.lo, such that the number represented by x is x.hi + x.lo, where
        |x.lo| <= 0.5*ulp(x.hi)
    
    and ulp(y) means "unit in the last place of y". The basic arithmetic operations are implemented using convenient properties of IEEE-754 floating-point arithmetic.

    The range of values which can be represented is the same as in IEEE-754. The precision of the representable numbers is twice as great as IEEE-754 double precision.

    The correctness of the arithmetic algorithms relies on operations being performed with standard IEEE-754 double precision and rounding. This is the Java standard arithmetic model, but for performance reasons Java implementations are not constrained to using this standard by default. Some processors (notably the Intel Pentium architecture) perform floating point operations in (non-IEEE-754-standard) extended-precision. A JVM implementation may choose to use the non-standard extended-precision as its default arithmetic mode. To prevent this from happening, this code uses the Java strictfp modifier, which forces all operations to take place in the standard IEEE-754 rounding model.

    The API provides both a set of value-oriented operations and a set of mutating operations. Value-oriented operations treat DoubleDouble values as immutable; operations on them return new objects carrying the result of the operation. This provides a simple and safe semantics for writing DoubleDouble expressions. However, there is a performance penalty for the object allocations required. The mutable interface updates object values in-place. It provides optimum memory performance, but requires care to ensure that aliasing errors are not created and constant values are not changed.

    This implementation uses algorithms originally designed variously by Knuth, Kahan, Dekker, and Linnainmaa. Douglas Priest developed the first C implementation of these techniques. Other more recent C++ implementation are due to Keith M. Briggs and David Bailey et al.

    References

    • Priest, D., Algorithms for Arbitrary Precision Floating Point Arithmetic, in P. Kornerup and D. Matula, Eds., Proc. 10th Symposium on Computer Arithmetic, IEEE Computer Society Press, Los Alamitos, Calif., 1991.
    • Yozo Hida, Xiaoye S. Li and David H. Bailey, Quad-Double Arithmetic: Algorithms, Implementation, and Application, manuscript, Oct 2000; Lawrence Berkeley National Laboratory Report BNL-46996.
    • David Bailey, High Precision Software Directory; http://crd.lbl.gov/~dhbailey/mpdist/index.html
    Implements
    IComparable
    IComparable<DD>
    Inherited Members
    object.Equals(object, object)
    object.GetType()
    object.ReferenceEquals(object, object)
    Namespace: NetTopologySuite.Mathematics
    Assembly: NetTopologySuite.dll
    Syntax
    [Serializable]
    public struct DD : IComparable, IComparable<DD>

    Constructors

    | Edit this page View Source

    DD(DD)

    Creates a DD with a value equal to the argument

    Declaration
    public DD(DD dd)
    Parameters
    Type Name Description
    DD dd

    The initial value

    | Edit this page View Source

    DD(double)

    Creates a new DD with value x.

    Declaration
    public DD(double x)
    Parameters
    Type Name Description
    double x

    The initial value

    | Edit this page View Source

    DD(double, double)

    Creates a new DD with value (hi, lo).

    Declaration
    public DD(double hi, double lo)
    Parameters
    Type Name Description
    double hi

    The high order component

    double lo

    The low order component

    | Edit this page View Source

    DD(string)

    Creates a new DD with value equal to the argument.

    Declaration
    public DD(string str)
    Parameters
    Type Name Description
    string str

    The value to initialize by

    Exceptions
    Type Condition
    FormatException

    if str is not a valid representation of a number

    Fields

    | Edit this page View Source

    E

    The value nearest to the constant e (the natural logarithm base).

    Declaration
    public static readonly DD E
    Field Value
    Type Description
    DD
    | Edit this page View Source

    Epsilon

    The smallest representable relative difference between two DD values

    Declaration
    public static readonly double Epsilon
    Field Value
    Type Description
    double
    | Edit this page View Source

    NaN

    A value representing the result of an operation which does not return a valid number.

    Declaration
    public static readonly DD NaN
    Field Value
    Type Description
    DD
    | Edit this page View Source

    PI

    The value nearest to the constant Pi.

    Declaration
    public static readonly DD PI
    Field Value
    Type Description
    DD
    | Edit this page View Source

    PiHalf

    The value nearest to the constant Pi / 2.

    Declaration
    public static readonly DD PiHalf
    Field Value
    Type Description
    DD
    | Edit this page View Source

    TwoPi

    The value nearest to the constant 2 * Pi.

    Declaration
    public static readonly DD TwoPi
    Field Value
    Type Description
    DD

    Properties

    | Edit this page View Source

    IsNegative

    Gets a value indicating whether this object is negative or not

    Declaration
    public bool IsNegative { get; }
    Property Value
    Type Description
    bool
    | Edit this page View Source

    IsZero

    Gets a value indicating whether this object is zero (0) or not

    Declaration
    public bool IsZero { get; }
    Property Value
    Type Description
    bool

    Methods

    | Edit this page View Source

    Abs()

    Returns the absolute value of this value.

    Special cases:
    • if this value is NaN, it is returned.
    Declaration
    public DD Abs()
    Returns
    Type Description
    DD

    The absolute value of this value

    | Edit this page View Source

    Ceiling()

    Returns the smallest (closest to negative infinity) value that is not less than the argument and is equal to a mathematical integer. Special cases:

    • If this value is NaN, returns NaN.
    Declaration
    public DD Ceiling()
    Returns
    Type Description
    DD

    The smallest (closest to negative infinity) value that is not less than the argument and is equal to a mathematical integer.

    | Edit this page View Source

    Clone()

    Creates and returns a copy of this value.

    Declaration
    public object Clone()
    Returns
    Type Description
    object

    A copy of this value

    | Edit this page View Source

    CompareTo(DD)

    Compares two DoubleDouble objects numerically.

    Declaration
    public int CompareTo(DD other)
    Parameters
    Type Name Description
    DD other

    An other DoubleDouble value

    Returns
    Type Description
    int

    -1,0 or 1 depending on whether this value is less than, equal to or greater than the value of other

    | Edit this page View Source

    CompareTo(object)

    Declaration
    public int CompareTo(object o)
    Parameters
    Type Name Description
    object o
    Returns
    Type Description
    int
    | Edit this page View Source

    Copy(DD)

    Creates a new DD with the value of the argument.

    Declaration
    public static DD Copy(DD dd)
    Parameters
    Type Name Description
    DD dd

    The value to copy

    Returns
    Type Description
    DD

    A copy of dd

    | Edit this page View Source

    Determinant(DD, DD, DD, DD)

    Computes the determinant of the 2x2 matrix with the given entries.

    Declaration
    public static DD Determinant(DD x1, DD y1, DD x2, DD y2)
    Parameters
    Type Name Description
    DD x1

    A matrix entry

    DD y1

    A matrix entry

    DD x2

    A matrix entry

    DD y2

    A matrix entry

    Returns
    Type Description
    DD

    The determinant of the matrix of values

    | Edit this page View Source

    Determinant(double, double, double, double)

    Computes the determinant of the 2x2 matrix with the given entries.

    Declaration
    public static DD Determinant(double x1, double y1, double x2, double y2)
    Parameters
    Type Name Description
    double x1

    A matrix entry

    double y1

    A matrix entry

    double x2

    A matrix entry

    double y2

    A matrix entry

    Returns
    Type Description
    DD

    The determinant of the matrix of values

    | Edit this page View Source

    Dump()

    Dumps the components of this number to a string.

    Declaration
    public string Dump()
    Returns
    Type Description
    string

    A string showing the components of the number

    | Edit this page View Source

    Equals(DD)

    Tests whether this value is equal to another DoubleDouble value.

    Declaration
    public bool Equals(DD y)
    Parameters
    Type Name Description
    DD y

    A DoubleDouble value

    Returns
    Type Description
    bool

    true if this value == y.

    | Edit this page View Source

    Equals(object)

    Declaration
    public override bool Equals(object obj)
    Parameters
    Type Name Description
    object obj
    Returns
    Type Description
    bool
    Overrides
    ValueType.Equals(object)
    | Edit this page View Source

    Floor()

    Returns the largest (closest to positive infinity) value that is not greater than the argument and is equal to a mathematical integer. Special cases:

    • If this value is NaN, returns NaN.
    Declaration
    public DD Floor()
    Returns
    Type Description
    DD

    The largest (closest to positive infinity) value that is not greater than the argument and is equal to a mathematical integer.

    | Edit this page View Source

    GetHashCode()

    Declaration
    public override int GetHashCode()
    Returns
    Type Description
    int
    Overrides
    ValueType.GetHashCode()
    | Edit this page View Source

    GreaterOrEqualThan(DD)

    Tests whether this value is greater than or equals to another DoubleDouble value.

    Declaration
    public bool GreaterOrEqualThan(DD y)
    Parameters
    Type Name Description
    DD y

    A DoubleDouble value

    Returns
    Type Description
    bool

    true if this value >= y.

    | Edit this page View Source

    GreaterThan(DD)

    Tests whether this value is greater than another DoubleDouble value.

    Declaration
    public bool GreaterThan(DD y)
    Parameters
    Type Name Description
    DD y

    A DoubleDouble value

    Returns
    Type Description
    bool

    true if this value > y.

    | Edit this page View Source

    IsInfinity(DD)

    Checks if value is infinity.

    Declaration
    public static bool IsInfinity(DD value)
    Parameters
    Type Name Description
    DD value

    A DoubleDouble value

    Returns
    Type Description
    bool

    true if value is infinity.

    | Edit this page View Source

    IsNaN(DD)

    Gets a value indicating whether this object is positive or not

    Declaration
    public static bool IsNaN(DD value)
    Parameters
    Type Name Description
    DD value
    Returns
    Type Description
    bool
    | Edit this page View Source

    IsPositive()

    Gets a value indicating whether this object is positive or not

    Declaration
    public bool IsPositive()
    Returns
    Type Description
    bool
    | Edit this page View Source

    LessOrEqualThan(DD)

    Tests whether this value is less than or equal to another DoubleDouble value.

    Declaration
    public bool LessOrEqualThan(DD y)
    Parameters
    Type Name Description
    DD y

    A DoubleDouble

    Returns
    Type Description
    bool

    true if this value is <= y

    | Edit this page View Source

    LessThan(DD)

    Tests whether this value is less than another DoubleDouble value.

    Declaration
    public bool LessThan(DD y)
    Parameters
    Type Name Description
    DD y

    A DoubleDouble value

    Returns
    Type Description
    bool

    true if this value is < y

    | Edit this page View Source

    Max(DD)

    Computes the maximum of this and another DD number.

    Declaration
    public DD Max(DD x)
    Parameters
    Type Name Description
    DD x

    A DD number

    Returns
    Type Description
    DD

    The maximum of the two numbers

    | Edit this page View Source

    Min(DD)

    Computes the minimum of this and another DD number.

    Declaration
    public DD Min(DD x)
    Parameters
    Type Name Description
    DD x

    A DD number

    Returns
    Type Description
    DD

    The minimum of the two numbers

    | Edit this page View Source

    Parse(string)

    Converts a string representation of a real number into a DoubleDouble value. The format accepted is similar to the standard Java real number syntax. It is defined by the following regular expression:

    [+|-] {digit} [ . {digit} ] [ ( e | E ) [+|-] {digit}+
    
    Declaration
    public static DD Parse(string str)
    Parameters
    Type Name Description
    string str

    The string to parse

    Returns
    Type Description
    DD

    The value of the parsed number

    Exceptions
    Type Condition
    FormatException

    Thrown if str is not a valid representation of a number

    | Edit this page View Source

    Pow(int)

    Computes the value of this number raised to an integral power. Follows semantics of .Net Math.Pow as closely as possible.

    Declaration
    [Pure]
    public DD Pow(int exp)
    Parameters
    Type Name Description
    int exp

    The integer exponent

    Returns
    Type Description
    DD

    x raised to the integral power exp

    | Edit this page View Source

    Reciprocal()

    Returns a DD whose value is 1 / this.

    Declaration
    public DD Reciprocal()
    Returns
    Type Description
    DD

    The reciprocal of this value

    | Edit this page View Source

    Rint()

    Rounds this value to the nearest integer. The value is rounded to an integer by adding 1/2 and taking the floor of the result. Special cases:

    • If this value is NaN, returns NaN.
    Declaration
    public DD Rint()
    Returns
    Type Description
    DD

    This value rounded to the nearest integer

    | Edit this page View Source

    Signum()

    Returns an integer indicating the sign of this value.

    • if this value is > 0, returns 1
    • if this value is < 0, returns -1
    • if this value is = 0, returns 0
    • if this value is NaN, returns 0
    Declaration
    public int Signum()
    Returns
    Type Description
    int

    An integer indicating the sign of this value

    | Edit this page View Source

    Sqr()

    Computes the square of this value.

    Declaration
    public DD Sqr()
    Returns
    Type Description
    DD

    The square of this value

    | Edit this page View Source

    Sqr(double)

    Computes the square of this value.

    Declaration
    public static DD Sqr(double x)
    Parameters
    Type Name Description
    double x
    Returns
    Type Description
    DD

    The square of this value.

    | Edit this page View Source

    Sqrt()

    Computes the positive square root of this value.

    If the number is NaN or negative, NaN is returned.
    Declaration
    public DD Sqrt()
    Returns
    Type Description
    DD

    If this is NaN or less than zero, the result is NaN.

    | Edit this page View Source

    Sqrt(double)

    Computes the positive square root of a DoubleDouble value.

    If the number is NaN or negative, NaN is returned.
    Declaration
    public static DD Sqrt(double x)
    Parameters
    Type Name Description
    double x

    A numeric value

    Returns
    Type Description
    DD

    the positive square root of this number.

    If the argument is NaN or less than zero, the result is NaN.
    | Edit this page View Source

    ToDoubleValue()

    Converts this value to the nearest double number.

    Declaration
    public double ToDoubleValue()
    Returns
    Type Description
    double

    The nearest double value

    | Edit this page View Source

    ToIntValue()

    Converts this value to the nearest int value.

    Declaration
    public int ToIntValue()
    Returns
    Type Description
    int

    The nearest int value

    | Edit this page View Source

    ToSciNotation()

    Returns the string representation of this value in scientific notation.

    Declaration
    public string ToSciNotation()
    Returns
    Type Description
    string

    The string representation in scientific notation

    | Edit this page View Source

    ToStandardNotation()

    Returns the string representation of this value in standard notation.

    Declaration
    public string ToStandardNotation()
    Returns
    Type Description
    string

    The string representation in standard notation

    | Edit this page View Source

    ToString()

    Returns a string representation of this number, in either standard or scientific notation. If the magnitude of the number is in the range [ 10-3, 108 ] standard notation will be used. Otherwise, scientific notation will be used.

    Declaration
    public override string ToString()
    Returns
    Type Description
    string

    A string representation of this number

    Overrides
    ValueType.ToString()
    | Edit this page View Source

    Truncate()

    Returns the integer which is largest in absolute value and not further from zero than this value.

    Special cases:
    • If this value is NaN, returns NaN.
    Declaration
    public DD Truncate()
    Returns
    Type Description
    DD

    The integer which is largest in absolute value and not further from zero than this value

    | Edit this page View Source

    ValueOf(double)

    Converts the double argument to a DoubleDouble number.

    Declaration
    public static DD ValueOf(double x)
    Parameters
    Type Name Description
    double x

    A numeric value

    Returns
    Type Description
    DD

    The extended precision version of the value

    | Edit this page View Source

    ValueOf(string)

    Converts the string argument to a DoubleDouble number.

    Declaration
    public static DD ValueOf(string str)
    Parameters
    Type Name Description
    string str

    A string containing a representation of a numeric value

    Returns
    Type Description
    DD

    The extended precision version of the value

    Exceptions
    Type Condition
    FormatException

    Thrown if str is not a valid representation of a number

    Operators

    | Edit this page View Source

    operator +(DD, DD)

    Returns the sum of lhs and rhs.

    Declaration
    public static DD operator +(DD lhs, DD rhs)
    Parameters
    Type Name Description
    DD lhs

    The left hand side

    DD rhs

    The right hand side

    Returns
    Type Description
    DD

    The sum of lhs and rhs

    | Edit this page View Source

    operator +(DD, double)

    Returns the sum of lhs and rhs.

    Declaration
    public static DD operator +(DD lhs, double rhs)
    Parameters
    Type Name Description
    DD lhs

    The left hand side

    double rhs

    The right hand side

    Returns
    Type Description
    DD

    The sum of lhs and rhs

    | Edit this page View Source

    operator /(DD, DD)

    Divides lhs by rhs.

    Declaration
    public static DD operator /(DD lhs, DD rhs)
    Parameters
    Type Name Description
    DD lhs

    A DoubleDouble numerator.

    DD rhs

    A DoubleDouble divisor.

    Returns
    Type Description
    DD

    The result of the division.

    | Edit this page View Source

    operator /(DD, double)

    Divides lhs by rhs.

    Declaration
    public static DD operator /(DD lhs, double rhs)
    Parameters
    Type Name Description
    DD lhs

    A DoubleDouble numerator.

    double rhs

    A double divisor.

    Returns
    Type Description
    DD

    The result of the division.

    | Edit this page View Source

    operator ==(DD, DD)

    Equality operator for DoubleDouble values

    Declaration
    public static bool operator ==(DD lhs, DD rhs)
    Parameters
    Type Name Description
    DD lhs

    A DoubleDouble value

    DD rhs

    A DoubleDouble value

    Returns
    Type Description
    bool

    true if lhs == rhs.

    | Edit this page View Source

    explicit operator DD(string)

    Operator to parse a DoubleDouble from a string

    Declaration
    public static explicit operator DD(string val)
    Parameters
    Type Name Description
    string val

    The DoubleDouble string

    Returns
    Type Description
    DD
    | Edit this page View Source

    implicit operator DD(double)

    Operator to convert the double value to a DoubleDouble value.

    Declaration
    public static implicit operator DD(double val)
    Parameters
    Type Name Description
    double val

    The DoubleDouble string

    Returns
    Type Description
    DD
    | Edit this page View Source

    operator !=(DD, DD)

    Inequality operator for DoubleDouble values

    Declaration
    public static bool operator !=(DD rhs, DD lhs)
    Parameters
    Type Name Description
    DD rhs

    A DoubleDouble value

    DD lhs

    A DoubleDouble value

    Returns
    Type Description
    bool

    true if lhs != rhs.

    | Edit this page View Source

    operator *(DD, DD)

    Multiplies lhs by rhs.

    Declaration
    public static DD operator *(DD lhs, DD rhs)
    Parameters
    Type Name Description
    DD lhs

    A DoubleDouble value.

    DD rhs

    A DoubleDouble value.

    Returns
    Type Description
    DD

    The result of the multiplication.

    | Edit this page View Source

    operator *(DD, double)

    Multiplies lhs by rhs.

    Declaration
    public static DD operator *(DD lhs, double rhs)
    Parameters
    Type Name Description
    DD lhs

    A DoubleDouble value.

    double rhs

    A double value.

    Returns
    Type Description
    DD

    The result of the multiplication.

    | Edit this page View Source

    operator -(DD, DD)

    Returns the difference of lhs and rhs.

    Declaration
    public static DD operator -(DD lhs, DD rhs)
    Parameters
    Type Name Description
    DD lhs

    The left hand side

    DD rhs

    The right hand side

    Returns
    Type Description
    DD

    The difference of lhs and rhs

    | Edit this page View Source

    operator -(DD, double)

    Returns the difference of lhs and rhs.

    Declaration
    public static DD operator -(DD lhs, double rhs)
    Parameters
    Type Name Description
    DD lhs

    The left hand side

    double rhs

    The right hand side

    Returns
    Type Description
    DD

    The difference of lhs and rhs

    | Edit this page View Source

    operator -(DD)

    Subtracts the argument from the value of this.

    Declaration
    public static DD operator -(DD val)
    Parameters
    Type Name Description
    DD val

    The subtrahend

    Returns
    Type Description
    DD

    The result of this - y

    Implements

    IComparable
    IComparable<T>
    • Edit this page
    • View Source
    In this article
    Back to top Generated by DocFX