By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
424,476 Members | 1,529 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 424,476 IT Pros & Developers. It's quick & easy.

ANDing and ORing question...

P: n/a
MLH
If I have an integer A and I logically AND it
with some other integer B to produce a result
C, can I then perform some kind of reverse
operation with B and C to get back the original
number A?

If so, is it guaranteed to work every time with
all integers A and B?
Nov 13 '05 #1
Share this Question
Share on Google+
4 Replies


P: n/a
No!
With AND, you may set one or more bits in A to zero. That information is
then lost.

MLH wrote:
If I have an integer A and I logically AND it
with some other integer B to produce a result
C, can I then perform some kind of reverse
operation with B and C to get back the original
number A?

If so, is it guaranteed to work every time with
all integers A and B?


--
Bas Cost Budde, Holland
http://www.heuveltop.nl/BasCB/msac_index.html
For human replies, replace the queue with a tea

Nov 13 '05 #2

P: n/a
On Sat, 02 Jul 2005 14:13:10 -0400, MLH <CR**@NorthState.net> wrote:

That's why we have XOR:

Sub x2()
Dim A As Integer
Dim B As Integer

A = 10 ' or any other number
B = 20 ' or any other number
A = A Xor B
A = A Xor B
Debug.Print A

End Sub
If I have an integer A and I logically AND it
with some other integer B to produce a result
C, can I then perform some kind of reverse
operation with B and C to get back the original
number A?

If so, is it guaranteed to work every time with
all integers A and B?


Nov 13 '05 #3

P: n/a
"MLH" <CR**@NorthState.net> wrote in message
news:04********************************@4ax.com...
If I have an integer A and I logically AND it
with some other integer B to produce a result
C, can I then perform some kind of reverse
operation with B and C to get back the original
number A?


Wwwwwhhhhhhhhhhaaaaaaaaaaaaaatttttttttttttttt?
Nov 13 '05 #4

P: n/a
Oh I see

"Bas Cost Budde" <b.*********@heuvelqop.nl> wrote in message
news:da**********@localhost.localdomain...
No!
With AND, you may set one or more bits in A to zero. That information is
then lost.

MLH wrote:
If I have an integer A and I logically AND it
with some other integer B to produce a result
C, can I then perform some kind of reverse
operation with B and C to get back the original
number A?

If so, is it guaranteed to work every time with
all integers A and B?


--
Bas Cost Budde, Holland
http://www.heuveltop.nl/BasCB/msac_index.html
For human replies, replace the queue with a tea

Nov 13 '05 #5

This discussion thread is closed

Replies have been disabled for this discussion.