Skip to content

Commit

Permalink
tryparse with nothing
Browse files Browse the repository at this point in the history
  • Loading branch information
JeffreySarnoff authored Mar 20, 2019
1 parent 73c9755 commit daee243
Showing 1 changed file with 6 additions and 6 deletions.
12 changes: 6 additions & 6 deletions src/type/parse.jl
Original file line number Diff line number Diff line change
Expand Up @@ -64,16 +64,16 @@ macro d16_str(val::AbstractString)
end

function tryparse(::Type{DoubleFloat{Float64}}, str::S; base::Int=10) where {S<:AbstractString}
bf = tryparse(BigFloat, str, base=base)
return DoubleFloat{Float64}(bf)
x = tryparse(BigFloat, str, base=base)
return ifelse(isnothing(x), nothing, DoubleFloat{Float64}(x))
end

function tryparse(::Type{DoubleFloat{Float32}}, str::S; base::Int=10) where {S<:AbstractString}
bf = tryparse(BigFloat, str, base=base)
return DoubleFloat{Float32}(bf)
x = tryparse(BigFloat, str, base=base)
return ifelse(isnothing(x), nothing, DoubleFloat{Float32}(x))
end

function tryparse(::Type{DoubleFloat{Float16}}, str::S; base::Int=10) where {S<:AbstractString}
bf = tryparse(BigFloat, str, base=base)
return DoubleFloat{Float16}(bf)
x = tryparse(BigFloat, str, base=base)
return ifelse(isnothing(x), nothing, DoubleFloat{Float16}(x))
end

0 comments on commit daee243

Please sign in to comment.