The Daily Static
  The Daily Static
UF Archives
Register
UF Membership
Ad Free Site
Postcards
Community

Geekfinder
UFie Gear
Advertise on UF

Forum Rules
& FAQ


Username

Password


Create a New Account

 
 

Back to UserFriendly Strip Comments Index

I was given a challenge for Perl; by caffine-iv2003-01-19 02:34:14
  Thats what I think about that... by Gorash2003-01-19 02:59:05
    a, b, c integers will work using xor by SMcV 2003-01-19 06:38:23
Assume a, b, c are CPU registers, x, y, z are constants, and C syntax.

a = x /* some number */
b = y /* some other number */
c = z /* some third number */

a ^= b
/* a == x^y */

b ^= c
/* b == y^z */

c ^= a
/* c == z^x^y */

a ^= c
/* a == z^x^y^x^y == z^x^x^y^y == z */

b ^= c
/* b == y^z^z^x^y == x */

c ^= a
/* c == z^x^y^z == y^x

c ^= b
/* c == y^x^x == y */

and now a, b, c contain the original values of c, a, b respectively, only the three variables a, b, c have changed, and no temporary expressions were evaluated (all modification was in-place).
[ Reply ]
      s,y^x$,y^x */, by SMcV2003-01-19 06:39:49
      Xyzzy! by Beorn2006-11-19 12:55:59

 

[Todays Cartoon Discussion] [News Index]

Come get yer ARS (Account Registration System) Source Code here!
All images, characters, content and text are copyrighted and trademarks of J.D. Frazer except where other ownership applies. Don't do bad things, we have lawyers.
UserFriendly.Org and its operators are not liable for comments or content posted by its visitors, and will cheerfully assist the lawful authorities in hunting down script-kiddies, spammers and other net scum. And if you're really bad, we'll call your mom. (We're not kidding, we've done it before.)