Skip to content

Commit

Permalink
Merge pull request #23348 from JuliaLang/teh/fix23300
Browse files Browse the repository at this point in the history
Fix #23300
  • Loading branch information
timholy authored Aug 20, 2017
2 parents c54e7ac + 1c2e689 commit e701561
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 1 deletion.
3 changes: 2 additions & 1 deletion base/twiceprecision.jl
Original file line number Diff line number Diff line change
Expand Up @@ -422,7 +422,7 @@ function rat(x)
y = x
a = d = 1
b = c = 0
m = maxintfloat(narrow(typeof(x)))
m = maxintfloat(narrow(typeof(x)), Int)
while abs(y) <= m
f = trunc(Int,y)
y -= f
Expand All @@ -435,6 +435,7 @@ function rat(x)
return a, b
end

narrow(::Type{T}) where {T<:AbstractFloat} = Float64
narrow(::Type{Float64}) = Float32
narrow(::Type{Float32}) = Float16
narrow(::Type{Float16}) = Float16
Expand Down
7 changes: 7 additions & 0 deletions test/ranges.jl
Original file line number Diff line number Diff line change
Expand Up @@ -957,3 +957,10 @@ end
@test logspace(a, b, n, base=base) == base.^linspace(a, b, n)
end
end

# Issue #23300
x = -5:big(1.0):5
@test map(Float64, x) === -5.0:1.0:5.0
@test map(Float32, x) === -5.0f0:1.0f0:5.0f0
@test map(Float16, x) === Float16(-5.0):Float16(1.0):Float16(5.0)
@test map(BigFloat, x) === x

0 comments on commit e701561

Please sign in to comment.