Saving an Operation or 20
Post by: Snarky on January 31st, 2007 | Filed Under Interests, ProgrammingGEEK ALERT, THIS WILL ONLY APPEAL TO YOU IF YOU LIKE ELEGANT CODING. YOU HAVE BEEN WARNED.
So, a friend two nights ago presented me with an interesting problem. How can one perform logical not (anything besides zero is true, zero is false) on a 32 bit int, without any tests, or control structures. I thought a minute and said, “I have the answer.”
*Warning, I dislike c… it’s been ages since I coded in it, and I gave answers in pseudo-code. I’ve been using Lua all day, so forgive mistakes. If you like, leave a comment, and I’ll fix it.*
Read More »
