2008-10-27, 10:49 AM
Devil's Sunrise Wrote:Depends on programming language and its level of abstraction. It'd take a lil time to do so in LISP, for example.
Yeah, well, if you're writing in LISP, efficiency (in time and/or space) is obviously not a priority.
In general, if you're writing in a high-level language, you trust your compiler to do whatever optimizations are necessary.
As I said before, the question at the start of the thread is mostly an intellectual exercise. A riddle.
Quote: I knew that it's possible to work with ASM in C#, but I've never really worked with it, so kill me on this one. heh.
What I wrote above wasn't ASM. It's pure C. I don't know C#, only C and C++, so I don't know whether C# has disabled such "careless" use of pointers. I wouldn't be surprised, though.
Quote:I checked speed of x0ring and temporarily value now, For 2^31-1 swappings, you'll use 1.7%-1.3% less time with temp. value.
On your processor (Intel?).
There are others where you'd use 100% more time using XOR. But the idea is to save space, not time.
Quote:Usually, you'll use...
while I sat in class I was like "duh, I coulda just said "hi guys pointers pls""
Unless, of course, the two data to be swapped reside in different address spaces. Possibly even on different machines.

