I have int field representing bitmask. Is there any functions available to work with bitmask? issetBit, unsetBit, setBit?
Thank you
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.
Use bitwise operators. But if you want functions, here you have some.
Usage: first argument is your current bitmask; second argument is the number of the bit (zero-based). I.e.
issetBit($mask, 2)equals(bool)($mask & 4)You cannot test/set/unset more than one bit at once with those functions though.