pBe Posted March 30, 2012 Posted March 30, 2012 Three more variations of a possible XOR function, for fun: I was looking for the thread where you explain logand/Boole/Logior. it took me a while to find it: http://www.cadtutor.net/forum/showthread.php?61237-I-want-just-Blocks-and-not-Xrefs/page2&highlight=LOGXOR Quote
Lee Mac Posted March 30, 2012 Posted March 30, 2012 Ah yes... bitwise logic Here's another: http://www.cadtutor.net/forum/showthread.php?45257-Simple-Setvar-request...&p=306339#post306339 Quote
irneb Posted March 30, 2012 Posted March 30, 2012 Nice explanation Irne Thanks Lee, nice alternatives. Though "logically" ... the one I've shown "should" be more efficient, since it uses only 4 function calls internally. Those you've shown uses 5, 5 & 7 respectively. I think we have discussed this previously, and come to the conclusion that practically there's not much in it - the differences are minute. Benchmarking ...................Elapsed milliseconds / relative speed for 65536 iteration(s): (XOR nil nil)......1435 / 1.04 <fastest> (XOR1 nil nil).....1435 / 1.04 (XOR3 nil nil).....1466 / 1.02 (XOR3 T nil).......1466 / 1.02 (XOR nil T)........1466 / 1.02 (XOR2 nil T).......1466 / 1.02 (XOR2 nil nil).....1467 / 1.02 (XOR2 T T).........1467 / 1.02 (XOR T nil)........1482 / 1.01 (XOR1 T nil).......1482 / 1.01 (XOR2 T nil).......1482 / 1.01 (XOR1 nil T).......1482 / 1.01 (XOR T T)..........1482 / 1.01 (XOR3 nil T).......1498 / 1 (XOR1 T T).........1498 / 1 (XOR3 nil T).......1498 / 1 <slowest> I've renamed yours to xor1, -2, & -3. As you see, the one I gave tends to be faster. But only fractionally (seems to be under 1%), the actual values seem to have a greater impact. Quote
Lee Mac Posted March 30, 2012 Posted March 30, 2012 Oh of course, mine aren't too readable either - I was just having fun with it Quote
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.