Re: Re: swapping variables

From: John Leavey (johnl_at_NO_SPAM.compufile.co.uk)
Date: 11/10/03


Date: Mon, 10 Nov 2003 15:23:24 +0000

On Mon, 10 Nov 2003 17:01:03 +0200, "Valentin Tihomirov" <valentin@abelectron.com> wrote:

>The following trick can be used when variables are of integer
> A := A + B;
> B := A - B;
> A := A - B;
>
>No need to use a temporary variable.

By the time you've added in sufficient comments to explain what this code is doing, you
might as well have used a temporary variable.

Also it will generate an overflow error if A + B > MaxInt

John Leavey