I am trying to store a negative value into a Redis bitset, but the operation fails with the following error:
bit offset is not an integer or out of range
Could some please explain why storing negative numbers in Redis bitsets isn't supported?
Because nobody refers to a position in a bitset using a negative number. A bitset in an array of bit, so its index is a positive integer.
If you have a negative number (for instance coming from a hashing function), then you need to convert it to an unsigned integer first. It is straightforward do to in most language.
In the specific case of Java, to cast a signed int to an unsigned value in the bottom 32 bits of a long, you need to AND with 0xffffffffL. See the following link: