Path: utzoo!attcan!uunet!ginosko!gem.mps.ohio-state.edu!csd4.csd.uwm.edu!mailrus!purdue!haven!adm!smoke!gwyn From: gwyn@smoke.BRL.MIL (Doug Gwyn) Newsgroups: comp.lang.c Subject: Re: swap(x,y) Message-ID: <10799@smoke.BRL.MIL> Date: 23 Aug 89 04:31:41 GMT References: Reply-To: gwyn@brl.arpa (Doug Gwyn) Organization: Ballistic Research Lab (BRL), APG, MD. Lines: 7 In article tg1e+@andrew.cmu.edu (Timothy R. Gottschalk) writes: > x += y; > y = x - y; > x -= y; This is an old trick (usually done using XOR instead of + and -). Your version can fail if arithmetic overflow occurs.