I think I need to use Bitwise with MySQL.
However, I’m confused with
SELECT 29 | 15;
returns
31
http://dev.mysql.com/doc/refman/5.0/en/bit-functions.html
I have been reading what I can understand about bitwise but I’m lost.
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
Well, in 29, the bits 16, 8, 4, and 1 are set.
In 15, the bits 8, 4, 2, and 1 are set.
“x Or y” (|) means: “set all bits that are set in x or y or both”.
So, in 29 | 15, bits 16, 8, 4, 2, and 1 are all set.
16 + 8 + 4 + 2 + 1 = 31.
Does this answer your question?