The SandmanBinary - Addition to Xor PostingWed Nov 11 19:54:42 1998 Greetings,Magenta, nice work on explaining how Xor works..:)I stress here that Assembly programming is NOT my langauge of choice and therefore not as good at it as I should be, so I oppologize here and now for any errors I make in this posting.I will add a little to Magenta's posting on how XOR works by explaining a little about Binary Numbers since XOR, AND,NOT, etc operates on Binary numbers..Binary is the computer's choice of langauge, programmers refer to this langauge as having a base of two. Decimal has a base of 10. Hex-decimal has a base of 16 and so on and so on. Human's natuaraly *think* in base of ten which makes adjusting to think in a different number base quite difficult..The Binary language comprises of 1's and 0's and nothing else, and while it's OK for a computer to run on, it has many disadvantages for humans to use, one of which is that it takes many sets of 1's and 0's to represent large numbers and to debug a program written soley in Binary would make even Einstien cry with frustration..Anyway....Since Binary is limited to series of 1's and 0's it takes a combination of eight 1's and 0's to represent a decimal number from 0 to 256. This is often referred to as a Byte, which is an 8-bit number. Examples of an 8-bit number:-11111111 = 25600000000 = 0In order to work out 'how' an 8-bit binary number corresponds to a decimal number goes something like this..Suppose you have the binary number 11001100 and want to convert it to decimal number then try and imagine a table like thisRow of Decimal Numbers 128 64 32 16 8 4 2 1 ----------------------------------Binary Number to convert: 1 0 0 1 1 0 0 1With the decimal numbers aligned along the 'top' all we have to do is ADD ALL the decimal numbers that have a '1' underneath it!. We don't add anything if their is a '0' underneath because it has no value as such.In our example, we would ADD 128+16+8+1 Which totals to 153 in decimal.So 10011001 = 153 Decimal.Here's another example...Suppose you want to convert 01010101 into a decimal number then using the above table we would see that:-Row of Decimal Numbers 128 64 32 16 8 4 2 1 ----------------------------------Binary Number to convert: 0 1 0 1 0 1 0 1can be converted into a decimal number by adding 64+16+4+1 which equals to a decimal number of 85.Now, if you want to work out what would be the result of XOR'ing a 8-bit decimal number by another 8-bit decimal number then first convert the two numbers to BINARY numbers, just turn the above table 'upside' down like this.Example: XOR 100 by 331st decimal number 100----------------------Binary Numbers 0 0 1 1 0 1 0 0 ----------------------------------Decimal Numbers 128 64 32 16 8 4 2 164 + 32 + 2 = 100 extactly.So our Binary number for 100 is: 001101002nd decimal number 33---------------------Binary Numbers 0 0 1 0 0 0 0 1 ----------------------------------Decimal Numbers 128 64 32 16 8 4 2 1So our Binary number for 33 is 00100001With these two numbers we can apply Magenta's posting on XOR to get the result of XOR'ing 100 by 33If this still doesn't make much sense to you then the Calculator that comes with Win 95/98 is able to do all this and more in a flash and requires no thinking on your part..:)Kind regardsThe Sandman