Just a quick question about the bitwise operator &.
If know that x & y == z and I know the value of y and z is there a way I can calculate the value of x?
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.
If you are told that x is unique, then no, there is no way of doing it for arbitrary values of y. Otherwise, there are 2n different solutions to that equation, where n is the number of zero bits of y.
As an example, let’s consider single bit numbers. If y is one, then the value of x must be the same as z (1&1 = 1; 0&1 = 0). If y is zero, z will also be zero, and x can be either one or zero (0&0 = 0; 1&0 = 0).
On many-bit numbers, every zero bit on y doubles the number of possible values of x, hence 2n