Re: Re: swapping variables
From: John Leavey (johnl_at_NO_SPAM.compufile.co.uk)
Date: 11/10/03
- Next message: David Knaack: "Re: Line number for debugging"
- Previous message: Rob Kennedy: "Re: Freeing a TList object and its Items"
- In reply to: Valentin Tihomirov: "Re: swapping variables"
- Next in thread: Rob Kennedy: "Re: swapping variables"
- Reply: Rob Kennedy: "Re: swapping variables"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
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
- Next message: David Knaack: "Re: Line number for debugging"
- Previous message: Rob Kennedy: "Re: Freeing a TList object and its Items"
- In reply to: Valentin Tihomirov: "Re: swapping variables"
- Next in thread: Rob Kennedy: "Re: swapping variables"
- Reply: Rob Kennedy: "Re: swapping variables"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]