DEV Community

Discussion on: How can you swap two variables without using a third?

Collapse
 
zhu48 profile image
Zuodian Hu

Oh and as prplz mentioned, any self-respecting compiler nowadays will use only registers any way you decide to implement this little stub of a function. Yes yes, the question is very contrived too, but hey.

Collapse
 
theoutlander profile image
Nick Karnik • Edited

Aren't you using a third register though?

Are you're thinking that you can do that because it's not in RAM?

Thread Thread
 
zhu48 profile image
Zuodian Hu

The way the question is formulated, you're limited by having a certain amount of memory. Any register use doesn't count against that at all.