Skip to content

Commit 4087d4f

Browse files
timholyararslan
authored andcommitted
Merge pull request #23348 from JuliaLang/teh/fix23300
Fix #23300 Ref #23348 (cherry picked from commit e701561)
1 parent 424f007 commit 4087d4f

File tree

2 files changed

+9
-1
lines changed

2 files changed

+9
-1
lines changed

base/twiceprecision.jl

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -422,7 +422,7 @@ function rat(x)
422422
y = x
423423
a = d = 1
424424
b = c = 0
425-
m = maxintfloat(narrow(typeof(x)))
425+
m = maxintfloat(narrow(typeof(x)), Int)
426426
while abs(y) <= m
427427
f = trunc(Int,y)
428428
y -= f
@@ -435,6 +435,7 @@ function rat(x)
435435
return a, b
436436
end
437437

438+
narrow(::Type{T}) where {T<:AbstractFloat} = Float64
438439
narrow(::Type{Float64}) = Float32
439440
narrow(::Type{Float32}) = Float16
440441
narrow(::Type{Float16}) = Float16

test/ranges.jl

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -921,3 +921,10 @@ let linsp = linspace(1.0, 2.0, 10)
921921
@test Float32(linsp.ref) === convert(Float32, linsp.ref)
922922
@test Float32(linsp.ref) linsp.ref.hi + linsp.ref.lo
923923
end
924+
925+
# Issue #23300
926+
x = -5:big(1.0):5
927+
@test map(Float64, x) === -5.0:1.0:5.0
928+
@test map(Float32, x) === -5.0f0:1.0f0:5.0f0
929+
@test map(Float16, x) === Float16(-5.0):Float16(1.0):Float16(5.0)
930+
@test map(BigFloat, x) === x

0 commit comments

Comments
 (0)