Yeah, so? Why would anyone want to do this? It's hard to understand and using a temp variable is clean and understandable.
WaltP
Posting Sage w/ dash of thyme
11,404 posts since May 2006
Reputation Points: 3,421
Solved Threads: 1,055
Skill Endorsements: 37
but when it comes to memory storage or allocation its better to go in this way,time efficience compare to using the third or temp variable
Really? Please show us why 4 extra bytes for a temp variable is slower than all that math. What are your sources for this assumption of speed vs memory useage? Document your position.
WaltP
Posting Sage w/ dash of thyme
11,404 posts since May 2006
Reputation Points: 3,421
Solved Threads: 1,055
Skill Endorsements: 37
but when it comes to memory storage or allocation its better to go in this way
Memory footprint is a viable argument, but I'd suggest that if the memory for a variable of type int is too much, you have bigger problems. I'm not sure what you mean by allocation though, as local variables are "allocated" with a simple adjustment of the stack pointer.
time efficience compare to using the third or temp variable
Using a temporary variable is all but guaranteed to be more efficient. This is a case of premature pessimization, where the "clever" optimization trick actually makes the code perform worse than the naive code would by confusing the compiler's optimization routines.
deceptikon
Challenge Accepted
3,445 posts since Jan 2012
Reputation Points: 822
Solved Threads: 473
Skill Endorsements: 57
I'm shocked nobody has pulled out the XOR trick yet. That's usually the first one that pops up when people try to show off the trivia they've learned that has no practical benefit in the real world.
deceptikon
Challenge Accepted
3,445 posts since Jan 2012
Reputation Points: 822
Solved Threads: 473
Skill Endorsements: 57
When developing in low-level languages, particularly assembly languages
You'll notice that this is the C forum, not the assembly forum.
when a low number of registers or limited memory is available
As I mentioned already, that can be a viable argument in favor of the tricks. But that's a niche area, and those platforms are the ones that don't support stdio.h (which you used in your OP). Further, when it is a viable argument, the caveats are made very clear to discourage use outside of the niche area, and you didn't do that. Rather, you tried to palm this off as a generally applicable and appropriate solution, which it isn't.
deceptikon
Challenge Accepted
3,445 posts since Jan 2012
Reputation Points: 822
Solved Threads: 473
Skill Endorsements: 57