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)
240
240
f > 0 ? lastindex (v) : firstindex (v)
241
241
else
242
242
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
244
252
end
245
253
else
246
254
idx_prev[]
Original file line number Diff line number Diff line change @@ -37,6 +37,7 @@ using SafeTestsets, Test
37
37
guesser_prev = Guesser (v, Ref (1 ), false )
38
38
@test guesser_linear. linear_lookup
39
39
@test searchsortedfirstcorrelated (v, 4.0 , guesser_linear) == 3
40
+ @test searchsortedfirstcorrelated (v, 1.4234326478e24 , guesser_linear) == 5
40
41
@test searchsortedlastcorrelated (v, 4.0 , guesser_prev) == 2
41
42
@test guesser_prev. idx_prev[] == 2
42
43
You can’t perform that action at this time.
0 commit comments