Skip to content
This repository was archived by the owner on Dec 10, 2023. It is now read-only.
This repository was archived by the owner on Dec 10, 2023. It is now read-only.

No sqrt(Double(0.0)) and sign(Double(0.0)) #9

Description

@ivanslapnicar

Simon,

presently sqrt(Double(0.0)) and sign(Double(0.0)) throw an error.
Possible remedy for sqrt is to change

# Dekker sqrt2
function sqrt{T}(x::Double{T})
    if x.hi <= 0
        throw(DomainError("sqrt will only return a complex result if called with a complex argument."))
    end
    c = sqrt(x.hi)
    u = Single(c)*Single(c)
    cc = (((x.hi - u.hi) - u.lo) + x.lo)*map(typeof(x.hi),0.5)/c
    double(c,cc)
end

into

# Dekker sqrt2
function sqrt{T}(x::Double{T})
    if x.hi = 0
         return Double(zero(T))
    end
    if x.hi < 0
        throw(DomainError("sqrt will only return a complex result if called with a complex argument."))
    end
    c = sqrt(x.hi)
    u = Single(c)*Single(c)
    cc = (((x.hi - u.hi) - u.lo) + x.lo)*map(typeof(x.hi),0.5)/c
    double(c,cc)
end

Cheers, Ivan

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions