SOLUTION: please explain
if a=5,
b=3;
then,
a^=b^=a^=b
result: a=3, b=5; (Swap)
please explain it...
Algebra.Com
Question 849323: please explain
if a=5,
b=3;
then,
a^=b^=a^=b
result: a=3, b=5; (Swap)
please explain it...
Answer by swincher4391(1107) (Show Source): You can put this solution on YOUR website!
Sounds like this is C.
So if we have a =5 and b =3,
we apply an XOR assignment operator.
b = a XOR b
So take 3 XOR 5 for instance. We write each in its 4-bit form
a = 3 XOR 5
(0011)(0101) = (0110) = 6
Now b = 3 a = 6
b = 6 XOR 3
(0110)(0011) = (0101) = 5
b = 5 a = 6
a = 6 XOR 5
(0110)(0101) = (0011) = 3
a = 3 b = 5
To understand what XOR means think of 1 and 0 as true and false. Know the truth table for XOR. It looks like OR but instead TT = F [the exclusive condition] which is why we call it an exclusive or.
Check out this page http://betterexplained.com/articles/swap-two-variables-using-xor/
Let me know if you have any questions!
-Devin
RELATED QUESTIONS
explain why a < b, then -a >... (answered by jim_thompson5910)
please prove..
if a>b then... (answered by MathLover1)
if a^n = b^n, then is a=b,... (answered by richwmiller)
If a^n=b then a is the nth root of b
true or false? please explain?
Thank you... (answered by rothauserc)
are the rational expressions a-b/b-a & b-a/a-b equivalent? explain... (answered by josgarithmetic)
if (a*a)+(b*b)=29 and ab=10 then find the values of a and b
please explain how to solve
(answered by josgarithmetic,ikleyn)
Please explain and show work.
Set A = (-3, 3) and set B = [-3, 3]
Find a)... (answered by Boreal)
Find the LCD of; 3/a, 3/b, 1/5, I thought that 5 was the LCD but it wasnt, could someone... (answered by jim_thompson5910)
If a=4 and b=5, then ab=45.
True or False? If False... (answered by stanbon)