English Deutsch Français Italiano Español Português 繁體中文 Bahasa Indonesia Tiếng Việt ภาษาไทย
All categories

9 answers

Here it is:

a=(a=a*b)/(b=a/b)

OM NAMAH SHIVAY

2006-12-27 04:44:24 · answer #1 · answered by Gurudev 3 · 0 0

If you knew the values were, for example, 8 bits you could say:
B = B << 8, B = A & B, A = B >> 8, B & '0000000011111111';

Of course this would only work for A & B values < 256.
Maybe not too helpful...

Never mind, that XOR thing looks pretty good.

2006-12-26 04:39:31 · answer #2 · answered by Crazy Malamute 3 · 0 0

Using what Programming Language?

2006-12-26 04:20:30 · answer #3 · answered by anothersillypersonalsname 2 · 0 0

can't be done in one line as far as I know, there is a really cool trick to swaping with binary, but i don't think that would work for your purpose.

if you could do it in 3 lines this code works:

a = a * b
b = a / b
a = a / b

2006-12-26 04:20:24 · answer #4 · answered by Tyler H 3 · 1 0

Using assembler:

xchg a,b

2006-12-26 11:41:37 · answer #5 · answered by Oleg T 2 · 0 0

I suppose you could do it with two pointers in C

Just reassign each pointer to the other location

2006-12-26 04:31:31 · answer #6 · answered by MarkG 7 · 0 0

You can use XOR.

http://en.wikipedia.org/wiki/XOR_swap_algorithm

2006-12-26 04:27:17 · answer #7 · answered by Barkley Hound 7 · 0 0

using the bitwise xor operator.

a^=b^=a^=b;

In detail, they are 4 statements

a=a^b;
b=b^a;
a=a^b;

2006-12-26 05:18:40 · answer #8 · answered by Kutti Jr 2 · 0 0

I HAVE NO IDEA.......

2006-12-26 05:16:28 · answer #9 · answered by Snowball 2 · 0 1

fedest.com, questions and answers