• Welcome to Valhalla Legends Archive.
 

Help With XOR

Started by R.a.B.B.i.T, November 03, 2004, 06:57 PM

Previous topic - Next topic

R.a.B.B.i.T

Well, that WOULD change the converted values...
But I didn't want to do XNOR, I wanted to do XOR!  Arg?  This is getting tricky, mostly due to the fact that we all seemed to have messed up on the binary example.  But whatever.  Back to my earlier question (which I think I should do): should I convert the values I want to XOR into binary, do the actual XORing, and then convert back, or something else?

Adron

Quote from: R.a.B.B.i.T on November 05, 2004, 04:36 PM
Well, that WOULD change the converted values...
But I didn't want to do XNOR, I wanted to do XOR!  Arg?  This is getting tricky, mostly due to the fact that we all seemed to have messed up on the binary example.  But whatever.  Back to my earlier question (which I think I should do): should I convert the values I want to XOR into binary, do the actual XORing, and then convert back, or something else?

If you just want to Xor values, you should be using the Xor operator....

If you want to rewrite it for some strange reason, you can use:

a Xor b = (a And Not b) Or (b And Not a)


R.a.B.B.i.T

I do want to rewrite it for some reason!  My original equation was just as you said, but resulted in low negatives:Dim A As Integer
Dim B As Integer
Dim Y As Integer
A = 5
B = 5
Y = ((Not A) And B) Or (A And Not B)
Debug.Print Y
This yeilded -60, as opposed to 0 (which the Xor operator gave me).  I believe that Visual BASIC has a thing against me. :'(

Adron

Quote from: R.a.B.B.i.T on November 06, 2004, 10:13 AM
I do want to rewrite it for some reason!  My original equation was just as you said, but resulted in low negatives:Dim A As Integer
Dim B As Integer
Dim Y As Integer
A = 5
B = 5
Y = ((Not A) And B) Or (A And Not B)
Debug.Print Y
This yeilded -60, as opposed to 0 (which the Xor operator gave me).  I believe that Visual BASIC has a thing against me. :'(

That's strange. My result is of course 0:

?((not 5) and 5) or (5 and not 5)
0

R.a.B.B.i.T

Eh, VB seems not to like me.  I'll try variations on the original code and see if I can get it to work, but so far nothing I've done seems to have worked.