Skip to content

Commit

Permalink
catch Inf
Browse files Browse the repository at this point in the history
  • Loading branch information
JeffreySarnoff authored Sep 14, 2018
1 parent 3cdd9c8 commit cfa1a18
Showing 1 changed file with 3 additions and 0 deletions.
3 changes: 3 additions & 0 deletions src/Double.jl
Original file line number Diff line number Diff line change
Expand Up @@ -66,16 +66,19 @@ const QuadrupleF16 = DoubleFloat{DoubleFloat{Float16}}
@inline DoubleFloat(x::Tuple{T,T}) where {T<:AbstractFloat} = DoubleFloat{T}(x[1], x[2])

@inline function Double64(x::T) where {T<:IEEEFloat}
!isfinite(x) && return(Double64(Float64(x),zero(T)))
hi = Float64(x)
lo = Float64(x - Float64(hi))
return Double64(hi, lo)
end
@inline function Double32(x::T) where {T<:IEEEFloat}
!isfinite(x) && return(Double32(Float32(x),zero(T)))
hi = Float32(x)
lo = Float32(x - Float64(hi))
return Double32(hi, lo)
end
@inline function Double16(x::T) where {T<:IEEEFloat}
!isfinite(x) && return(Double16(Float16(x),zero(T)))
hi = Float16(x)
lo = Float16(x - Float64(hi))
return Double16(hi, lo)
Expand Down

0 comments on commit cfa1a18

Please sign in to comment.