Tuesday, 15 September 2015

bit manipulation - MySQL bit inversion, how to only negate the fist x bits? -



bit manipulation - MySQL bit inversion, how to only negate the fist x bits? -

i using bitwise operators in mysql. have column of 6 bits. when used bit negation operator "~" 64 bt integer returned. means have number of leading 1's don't want.

how negate lastly 6 bits (the rightmost 6 bits)?

you can utilize xor 1 bits set each bit want negate.

in case, xor 0b00111111, or 0x3f.

mysql bit-manipulation

No comments:

Post a Comment