Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

searchsorted on interesting ranges #34408

Open
jw3126 opened this issue Jan 16, 2020 · 3 comments
Open

searchsorted on interesting ranges #34408

jw3126 opened this issue Jan 16, 2020 · 3 comments
Labels
domain:ranges Everything AbstractRange kind:bug Indicates an unexpected problem or unintended behavior kind:correctness bug ⚠ Bugs that are likely to lead to incorrect results in user code without throwing

Comments

@jw3126
Copy link
Contributor

jw3126 commented Jan 16, 2020

Inspired by @TotalVerb #34315 (comment)

julia> r = 1f8-10:1f8
9.999999f7:1.0f0:1.0f8

julia> searchsorted(r, 1f8)
9:9

julia> searchsorted(collect(r), 1f8)
5:9
@brenhinkeller brenhinkeller added the domain:ranges Everything AbstractRange label Nov 20, 2022
@aplavin
Copy link
Contributor

aplavin commented Feb 5, 2023

Also encountered this bug! Seems like now all ranges searchsorted return singleton index ranges, so presumably quite a lot should be changed to fix...

@oscardssmith oscardssmith added the kind:bug Indicates an unexpected problem or unintended behavior label Feb 5, 2023
@oscardssmith
Copy link
Member

This range math is always fun.

@LilithHafner LilithHafner added the kind:correctness bug ⚠ Bugs that are likely to lead to incorrect results in user code without throwing label Aug 7, 2023
@Moelf
Copy link
Sponsor Contributor

Moelf commented Oct 31, 2023

julia> r = 1f8-10:1f8

julia> collect(r)
9-element Vector{Float32}:
 9.999999f7
 9.999999f7
 9.999999f7
 9.999999f7
 1.0f8
 1.0f8
 1.0f8
 1.0f8
 1.0f8

this is considered correct? Basically, do we want both to return 9:9(not really possible) or both to return 5:9(possible but feels wrong for the range).


Seems like now all ranges searchsorted return singleton index ranges,

Presumably because ranges have higher precision (twice precision), so even though there are duplicated elements when you collect(), if you keep it as a range it can tell each element is unique

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
domain:ranges Everything AbstractRange kind:bug Indicates an unexpected problem or unintended behavior kind:correctness bug ⚠ Bugs that are likely to lead to incorrect results in user code without throwing
Projects
None yet
Development

No branches or pull requests

6 participants