Bitwise AND operation backwards

  • Thread starter Mc_Topaz
  • Start date
In summary, the conversation discusses a method for calculating a product's serial number from a given MAC address using a bitwise AND operation. The equation is reversible, but only if the inverse operation also includes the bitwise AND of the source value with the inverse of the constant. Without this, the solution is not possible.
  • #1
Mc_Topaz
1
0

Homework Statement



At my company we calculate a product's serial number from a MAC address provided with the unit. One of the equations is done with a bitwise AND operation of two integers. I have tried to run that equation backwards but with no result.

Variables and data:

V = The source value to do the bitwise AND operation with
C = A known constant to use in the bitwise AND operation
S = Result of bitwise AND operation

Let say: V = 10, C = 6

Homework Equations



The equation forward is: V & C = S => 10 & 6 = 2

In binary:

1010 = 10
0110 = 6
-----
0010 = 2


Now I just want to reverse that process and calculate 10 from 6 and 2 in some way.

Don't try with: C + 2S (6 + (2*2)) works just in this case.

The Attempt at a Solution



I tried the opposite way by changing V for S:

2 & 6 = 2

In binary:

0010 = 2
0110 = 6
-----
0010 = 2


The problem occurs when one of the bits in the V is 1 and the equivalent bit in C is 0. The bit in S will then be 0 and V's bit can never return to 1.

Any suggestions?

/Mc_Topaz
 
Physics news on Phys.org
  • #2
Unfortunately that's just not possible as it's a many to one mapping. Of the three main two input binary operators (AND OR XOR) only XOR is invertible like that.
 
  • #3
It would be possible if you also knew V & ~C, though. Since A & B only has ones where both A and B have ones, and ~B has ones only where B has zeros, V & ~C has the 'missing ones' from the other calculation.
 
  • #4
Strants said:
It would be possible if you also knew V & ~C, though. Since A & B only has ones where both A and B have ones, and ~B has ones only where B has zeros, V & ~C has the 'missing ones' from the other calculation.

Actually "V" is the thing he's trying to find (given S and C). Knowledge of ~C provides no new information and doesn't help with the original problem. Since he knows C then he already knows ~C anyway.
 
Last edited:
  • #5

The bitwise AND operation is a logical operator that compares the corresponding bits in two numbers and returns a new number with a 1 in each bit position where both numbers have a 1. This operation is not reversible, meaning that you cannot determine the original numbers from the result of a bitwise AND operation. This is because the operation discards information about the individual bits and only considers the overall pattern of 1s and 0s.

In your example, the result of the bitwise AND operation (2) does not contain enough information to determine the original numbers (10 and 6). Therefore, it is not possible to calculate 10 from 6 and 2 using a bitwise AND operation.

If you need to calculate the original numbers from the result of a bitwise AND operation, you will need to use additional information or equations. For example, if you know the value of C and the result of the operation, you can use algebra to solve for V. However, this will require more information than just the result of the bitwise AND operation.
 

1. What does the bitwise AND operation backwards do?

The bitwise AND operation backwards is a mathematical operation that takes two binary inputs and performs a logical AND operation on each bit in reverse order. This means that the last bit of one input is compared to the first bit of the other input, and so on until all bits have been compared. The result is a binary output that represents the logical AND of the two inputs.

2. How does the bitwise AND operation backwards differ from the regular bitwise AND operation?

The regular bitwise AND operation compares each bit in the same order, starting from the first bit of each input. This means that the first bit of one input is compared to the first bit of the other input, and so on until all bits have been compared. The result is the same as the bitwise AND operation backwards, but the bits are ordered differently.

3. Can the bitwise AND operation backwards be used with non-binary numbers?

No, the bitwise AND operation backwards can only be performed on binary numbers. It is a mathematical operation that is used to manipulate binary data at the bit level.

4. What is the purpose of using the bitwise AND operation backwards?

The bitwise AND operation backwards is often used in cryptography and data compression algorithms. It can also be used to manipulate and analyze binary data in computer programs.

5. What are the applications of the bitwise AND operation backwards in computer science?

Aside from its use in cryptography and data compression, the bitwise AND operation backwards can also be used in data masking, error detection and correction, and bitwise operations on bitarrays. It is an important tool in computer science for manipulating and analyzing binary data.

Similar threads

  • Engineering and Comp Sci Homework Help
Replies
2
Views
4K
  • Engineering and Comp Sci Homework Help
Replies
9
Views
1K
  • Engineering and Comp Sci Homework Help
Replies
4
Views
2K
  • Engineering and Comp Sci Homework Help
Replies
10
Views
2K
  • Engineering and Comp Sci Homework Help
Replies
4
Views
1K
  • Engineering and Comp Sci Homework Help
Replies
0
Views
485
  • Engineering and Comp Sci Homework Help
Replies
2
Views
2K
  • Engineering and Comp Sci Homework Help
Replies
3
Views
1K
  • Engineering and Comp Sci Homework Help
Replies
2
Views
2K
  • Engineering and Comp Sci Homework Help
Replies
5
Views
2K
Back
Top