File tree Expand file tree Collapse file tree 2 files changed +10
-1
lines changed Expand file tree Collapse file tree 2 files changed +10
-1
lines changed Original file line number Diff line number Diff line change @@ -240,7 +240,15 @@ function (g::Guesser)(x)
240240 f > 0 ? lastindex (v) : firstindex (v)
241241 else
242242 i_0, i_f = firstindex (v), lastindex (v)
243- round (typeof (firstindex (v)), f * (i_f - i_0) + i_0)
243+ i_approx = f * (i_f - i_0) + i_0
244+ target_type = typeof (firstindex (v))
245+ if i_approx >= typemax (target_type)
246+ lastindex (v) + 1
247+ elseif i_approx <= typemin (target_type)
248+ firstindex (v) - 1
249+ else
250+ round (target_type, i_approx)
251+ end
244252 end
245253 else
246254 idx_prev[]
Original file line number Diff line number Diff line change @@ -37,6 +37,7 @@ using SafeTestsets, Test
3737 guesser_prev = Guesser (v, Ref (1 ), false )
3838 @test guesser_linear. linear_lookup
3939 @test searchsortedfirstcorrelated (v, 4.0 , guesser_linear) == 3
40+ @test searchsortedfirstcorrelated (v, 1.4234326478e24 , guesser_linear) == 5
4041 @test searchsortedlastcorrelated (v, 4.0 , guesser_prev) == 2
4142 @test guesser_prev. idx_prev[] == 2
4243
You can’t perform that action at this time.
0 commit comments