[RESOLVED] Understanding XOR
I am trying to understand how XOR works. Why is this equal to 25?
Just testing this:
Code:
Public Sub Main()
Dim intFix As Integer
intFix = Fix(256 * Rnd)
Range("A1").Value = intFix
Dim intAsc As Integer
intAsc = Asc(Mid$("Test", 1, 1))
Range("A2").Value = intAsc
Range("A3").Value = intFix Xor intAsc
MsgBox 77 Xor 84
End Sub
Re: [RESOLVED] Understanding XOR
One last question, when I convert binary to decimal, do i convert binary to hex or decimal to hex?
Re: [RESOLVED] Understanding XOR
Quote:
Originally Posted by Liquid Metal
One last question, when I convert binary to decimal, do i convert binary to hex or decimal to hex?
It doesn't matter you can convert from Decimal to Octal to Binary to Hex and back to Octal if you want or any combination in between. You don't need to be in one particular base inorder to convert to another base.
Re: [RESOLVED] Understanding XOR
You don't really convert anything. They are the same value represented differently.
Binary = 2 base
Decimal = 10 base
Hex = 16 base
In VB code you can't write bits directly, but decimals and hex are supported. When you write...
Code:
lngSomething = 10
lngSomething = &HA
... you do the exact same thing. There is no difference in the final compiled code and there is no executional difference. The value is just represented in different base. If binary representation would be supported, the end result would be the same with it.
Basically one uses hex values in VB code to ease understanding the code... like, when you see F, you know all four bits are being active.
Code:
' only highest bit remains active if it is there
bytSomething = bytSomething And &H80
' only high order bits remain active
bytSomething = bytSomething And &HF0
' only low order bits remain active
bytSomething = bytSomething And &H0F
' all except the highest bit remain active
bytSomething = bytSomething And &H7F
Re: [RESOLVED] Understanding XOR
Thanks
I actually found this site and it make so much sense now, especially looking at the last table.
http://www.permadi.com/tutorial/numHexToBin/index.html
Merri, I noticed an "H" in your code. Hex only goes up to "F". Is the "H" a VB representation of Hex format?
Re: [RESOLVED] Understanding XOR
&H tells the compiler the following values are hex numbers.
Re: [RESOLVED] Understanding XOR