bitpos
BITPOS
Find the position of the specified bit
Usage is bitpos key bit [start [end]].
Shows the position of the specified bit as a bit offset.
start and end are byte offsets starting from 0.
Negative values can be used for start or end. In that case the last byte is -1, the previous one is -2, and so on.
Example
| Command> | set key ABC
|
| Result> | OK
|
| Command> | bitpos key 0
|
| Result> | 0
|
| Command> | bitpos key 1
|
| Result> | 1
|
| Command> | bitpos key 1 2
|
| Result> | 17
|
View animation
Syntax
BITPOS key bit [start [end]]
- Available since version 2.8.7.
- Time complexity is O(N).