Skip to content

Commit a02400f

Browse files
committed
More accurate Base.lerpi for higher-precision numbers
Fixes: #37276
1 parent 662e24c commit a02400f

File tree

2 files changed

+10
-1
lines changed

2 files changed

+10
-1
lines changed

base/range.jl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -685,7 +685,7 @@ end
685685

686686
function lerpi(j::Integer, d::Integer, a::T, b::T) where T
687687
@_inline_meta
688-
t = j/d
688+
t = eltype(T)(j)/d
689689
T((1-t)*a + t*b)
690690
end
691691

test/ranges.jl

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1326,6 +1326,15 @@ end
13261326
@test r[4] === 3.0+im
13271327
end
13281328

1329+
@testset "issue #37276" begin
1330+
r = range(Complex{BigFloat}(0), stop=Complex{BigFloat}(1), length=4)
1331+
@test isa(@inferred(r[2]), Complex{BigFloat})
1332+
@test r[1] == 0.
1333+
@test r[2] big"1"/3
1334+
@test r[3] big"2"/3
1335+
@test r[4] == 1.
1336+
end
1337+
13291338
# ambiguity between (:) methods (#20988)
13301339
struct NotReal; val; end
13311340
Base.:+(x, y::NotReal) = x + y.val

0 commit comments

Comments
 (0)