Bitwise AND operation backwards

  • Thread starter Thread starter Mc_Topaz
  • Start date Start date
Click For Summary

Discussion Overview

The discussion revolves around the challenge of reversing a bitwise AND operation to retrieve the original value from known constants and results. It includes theoretical considerations of binary operations and their properties, particularly focusing on the implications of the many-to-one nature of the AND operation.

Discussion Character

  • Homework-related
  • Technical explanation
  • Debate/contested

Main Points Raised

  • One participant describes the problem of calculating the original value (V) from a known constant (C) and the result of the bitwise AND operation (S), providing specific numerical examples.
  • Another participant asserts that reversing the AND operation is impossible due to it being a many-to-one mapping, contrasting it with the XOR operation, which is invertible.
  • Some participants suggest that knowing the value of V & ~C could potentially aid in retrieving V, as it would provide information about the bits that are not set in C.
  • However, a later reply challenges this idea, stating that knowledge of ~C does not provide new information since C is already known, thus not assisting in solving for V.

Areas of Agreement / Disagreement

Participants generally disagree on the feasibility of reversing the bitwise AND operation. While some propose additional information could help, others maintain that it remains fundamentally impossible due to the nature of the operation.

Contextual Notes

The discussion highlights the limitations of the AND operation in terms of information retrieval, emphasizing the conditions under which certain binary operations can be inverted.

Mc_Topaz
Messages
1
Reaction score
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
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.
 
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.
 
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:

Similar threads

  • · Replies 2 ·
Replies
2
Views
3K
  • · Replies 4 ·
Replies
4
Views
3K
  • · Replies 10 ·
Replies
10
Views
2K
  • · Replies 2 ·
Replies
2
Views
3K
  • · Replies 9 ·
Replies
9
Views
2K
  • · Replies 2 ·
Replies
2
Views
2K
  • · Replies 1 ·
Replies
1
Views
1K
  • · Replies 2 ·
Replies
2
Views
11K
  • · Replies 1 ·
Replies
1
Views
1K
  • · Replies 3 ·
Replies
3
Views
3K