Challenge: Identify ways to use XOR logical operator - Printable Version +- Qbasicnews.com (http://qbasicnews.com/newforum) +-- Forum: QbasicNews.Com (http://qbasicnews.com/newforum/forum-3.html) +--- Forum: Challenges (http://qbasicnews.com/newforum/forum-10.html) +--- Thread: Challenge: Identify ways to use XOR logical operator (/thread-1277.html) |
Challenge: Identify ways to use XOR logical operator - oracle - 06-21-2003 Ooooooohh... maybe that's why no-one uses XOR :rotfl: Re: To drV: - DrV - 06-21-2003 Quote:Excellent. Your example is a classic. You must be an assembly language programmer. ... Hehe... actually, I read that in VBPJ a looong time ago, and this thread made me remember it, so I went digging around for about 20 minutes and finally found it. To Toonski84 - Moneo - 06-21-2003 Ok, I'll take your word for it. the n=1-n may be faster than the n=n xor 1, but it's not as elegant. Plus, since I learned this trick in assembler, you coudn't do the n=1-n in one instruction in most assemblers that i've seen. But nevertheless, you win for now. ***** Challenge: Identify ways to use XOR logical operator - toonski84 - 06-21-2003 yeah, it's more elegant. it also takes a 10th of a second longer to do 10 million operations. remember: when you're doing 10,000,000 switches, you're going to need all the speed you can get! Challenge: Identify ways to use XOR logical operator - Antoni Gual - 06-21-2003 XOR? Mmmh.. 1.- I use it often to create a cheap texture Code: screen 13 Edited: Nr 2 did'nt worked... 3.- The CRC algorithm is based on XOR (Code ripped from ABC) Code: CRC = 0 'Reset for Each Text Block 4.- The sprite animation technique often suggested to newbies: Excuse me if it's not exactly like this, you never find those darn snippets when you need them... Code: PUT (x,y), mask(0), XOR edited: BTW: Have you ever used EQV ? Not me.... Challenge: Identify ways to use XOR logical operator - Agamemnus - 06-21-2003 XOR is good, but it's a crappy name. OR is good, AND is good. You can figure those out right off the bat. But XOR? Come on men and women. Can't they make something cooler? Like.. "Addition of two bits without carry" Challenge: Identify ways to use XOR logical operator - Moneo - 06-21-2003 TO ANTONI: Yes, the CRC calculation is probably one of the most popular uses of the XOR. The LRC (Longitudinal Redundancy Character or Check) used on some mainframe magnetic tape units, is a simpler computation that also uses the XOR, but is a less robust error checking technique than the CRC. If anyone is interested, I have the "C" code for generating the identical CRC used by PKZIP. I didn't concieve it, but I fixed it to work. x EQV y EQV stands for Equivalent, meaning it tests if the expressions X and Y are the "same", i.e., either both true or both false. I honestly have never had an opportunity to use it. ----------------------------------------------------------------------------------- TO AGAMEMNUS: Regarding the name of XOR, i.e., exclusive-or. The story that I heard years ago is that a regular OR is an inclusive-or. If either of the bits is on, then the resultant bit will be inclusively on. But, for an XOR, if the bits are both on, then the resultant bit will be exclusively off. OK, not the best definition. Note that in some languages an XOR is written as EOR. ***** Challenge: Identify ways to use XOR logical operator - HystericPoison - 06-22-2003 thats all too confusing for me...il just use my 300 line IF statements...at least they make sense to me Challenge: Identify ways to use XOR logical operator - LooseCaboose - 06-22-2003 Quote:Your second example about doing things the long way reminds me of my favorite example which is for using a flip/flop switch. If the switch is on (a one), you want to turn it off. If the switch is off (zero), you want to turn it on. Err... Code: flipflop = !flipflop Re: To drV: - relsoft - 06-22-2003 Quote:Excellent. Your example is a classic. You must be an assembly language programmer. In assembler you find your self doing this method to swap the contents of two registers without having to use another intermediate register or time-consuming stores to memory. I usually use XCHG. ;*) |