Description
The following behaviors have been causing bugs in some code of mine:
searchsortedlast([0.0, 1.0], +0.0) # returns 1
searchsortedlast([0.0, 1.0], -0.0) # returns 0
searchsorted([0.0], +0.0) # returns 1:1
searchsorted([0.0], -0.0) # returns 1:0
searchsorted([0.0], 0.0; lt=<=) # returns 2:1
In all cases I encountered, I could get away with it by using searchsortedXXXX(args... ; lt=<)
.
However, assuming the above behavior is what's intended, I believe there's an inconsistency in the docs.
For instance, for searchsorted
:
searchsorted(a, x; by=<transform>, lt=<comparison>, rev=false)
Return the range of indices of a which compare as equal to x (using binary search) according to
the order specified by the by, lt and rev keywords, assuming that a is already sorted in that order.
Return an empty range located at the insertion point if a does not contain values equal to x.
It's hard to believe that [0.0]
does not contain any value equal to 0.0
😅
If it's a bug, I probably can't fix it, but if it's intended and clarifying the docs would be satisfactory, then I'm happy to do so.