in reply to Flipping bits and using flags

BMaximus,
You had me all up until the point where you said you had a 5 bit flag at positions 1, 2, 4, 8, and 16 respectively. The handful of times I have used bitstrings - I have used vec and just looked at the literal bit of the string to see if it was set or not.
print vec($bitstr, $pos, 1) ? 'on' : 'off';
This assumes that bit 6 is at pos 5 since $pos is really an offset (0 based). You can also use pack and unpack [bB] format to convert back and forth between strings like '01100111' and bitstrings.

While what my reply has little to nothing to do with what you are doing with MySQL and sets, I didn't want others to be scared of bitstrings just because they sound scary. They can be quite simple.

Cheers - L~R

Replies are listed 'Best First'.
Re^2: Flipping bits and using flags
by BMaximus (Chaplain) on Mar 23, 2006 at 21:58 UTC
    I think you misunderstood me and I can see why. I said position when I meant bit value. In binary the position values are (if I understand this right) are 1,2,4,8 and 16 respectively. I'll correct my question to reflect what I really meant.

    BMaximus