Skip to content

Feedback: BITPOS example result is totally wrong #993

@raffertyyu

Description

@raffertyyu

Page https://redis.io/docs/latest/commands/bitpos/

reference to the examples:

redis> SET mykey "\xff\xf0\x00"
"OK"
redis> BITPOS mykey 0
(integer) 0
redis> SET mykey "\x00\xff\xf0"
"OK"
redis> BITPOS mykey 1 0
(integer) 1
redis> BITPOS mykey 1 2
(integer) 18
redis> BITPOS mykey 1 2 -1 BYTE
(integer) 18
redis> BITPOS mykey 1 7 15 BIT
(integer) 9
redis> set mykey "\x00\x00\x00"
"OK"
redis> BITPOS mykey 1
(integer) 1
redis> BITPOS mykey 1 7 -3 BIT
(integer) 9
redis> 

however, actual and correct result should be (run on redis 7)

redis> SET mykey "\xff\xf0\x00"
OK
redis> BITPOS mykey 0
(integer) 12
redis> SET mykey "\x00\xff\xf0"
OK
redis> BITPOS mykey 1 0
(integer) 8
redis> BITPOS mykey 1 2
(integer) 16
redis> BITPOS mykey 1 2 -1 BYTE
(integer) 16
redis> BITPOS mykey 1 7 15 BIT
(integer) 8
redis> set mykey "\x00\x00\x00"
OK
redis> BITPOS mykey 1
(integer) -1
redis> BITPOS mykey 1 7 -3 BIT
(integer) -1
redis>

Metadata

Metadata

Assignees

Labels

bugSomething isn't workingdev

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions