Private Sub Command1_Click()
Dim b1 As Byte, b2 As Byte
b1 = 0
b2 = 16
MsgBox b1 Xor b2 ' = 16 As bit 5 is Set In only one
End Sub
Private Sub Command1_Click()
Dim b1 As Byte, b2 As Byte
b1 = 16 'bit 5 Set
b2 = 16 'bit 5 Set
MsgBox b1 Xor b2 '0 As bit 5 is Set In both
End Sub
xor stands for exclusive or and is a boolean logic comparation operator defined as:
P != q = (¬p ^ q) v (p ^ ¬q)
and is analogous with <> operator for aritmetical comparations.
true xor false is true
false xor true is true
false xor false is false
true xor true is false
boolean xor operator should not be mixed with the bitwise xor operator, which is used to compare bits of aritmetical numbers.
Last edited by kedaman; Apr 20th, 2001 at 02:34 AM.
Use
writing software in C++ is like driving rivets into steel beam with a toothpick.
writing haskell makes your life easier:
reverse (p (6*9)) where p x|x==0=""|True=chr (48+z): p y where (y,z)=divMod x 13
To throw away OOP for low level languages is myopia, to keep OOP is hyperopia. To throw away OOP for a high level language is insight.
Use
writing software in C++ is like driving rivets into steel beam with a toothpick.
writing haskell makes your life easier:
reverse (p (6*9)) where p x|x==0=""|True=chr (48+z): p y where (y,z)=divMod x 13
To throw away OOP for low level languages is myopia, to keep OOP is hyperopia. To throw away OOP for a high level language is insight.
In the 70's when memory was really expensive, it was a challenge to get most out of a given amount of RAM or whatever storage one was using. Consequently, the art of XOR 'ing and ANDOR'ing needed to be mastered, just so that a problem could be solved. You probably understand that XOR/ANDOR allows one to flip the bits in a byte in a logical manner so as to acheive a new status or value within the byte. Logically, a byte can store 8 bits ON or OFF, so in simple terms, we can store up to 8 switch values or True/False values in a single byte - WOW!!!!
Now that we have arrived in 2001, the instruction capability remains in the languages, but the need to apply the instructions is not entirely relevant today. (Saving a few bytes is not the name of the game any more, rather, understandable, preferably self documenting code is the way of success in a piece of software). So, are you an academic or are you a worker?
Understand and explore the world of bits if you must, but do it in your own time - a company employing you will not thank you for the wonders you can acheive with XOR/ANDOR (unless they are trying to fit a massive application on the face of a 4k Chip).
And do spare a thought for those who follow - they may need to fix some problem you create, and working in the underworld of bits ain't much joy.
I do admire some dedicated developers who use the technique of XOR/ANDOR through a controlable subroutine, to acheive massive arrays of switches. Suggest you visit www.Softcircuits.com where you will find one such piece of code.