BITPOS
Since 1.1.0Bitmaps
Syntax
BITPOS key bit [start [end [BYTE | BIT]]]Returns the position of the first bit set to bit (0 or 1) in the string at key, or in a part of it. start and end are byte offsets, unless BIT is given.
Reply
- The position, counted in bits from the start of the string.
-1if no bit is set to1, when looking for1.- When looking for
0in a string of only1s, with noendgiven: the first bit past the string. A missing key gives0for bit0and-1for bit1.
Examples
> SETBIT one 3 1
(integer) 0
> BITPOS one 1
(integer) 3
> BITPOS one 0
(integer) 0
> BITPOS missing 1
(integer) -1