www.delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp/1999/10/01/16:29:49

Date: Fri, 1 Oct 1999 16:20:23 -0400 (EDT)
From: Daniel Reed <djr AT narnia DOT n DOT ml DOT org>
Sender: n AT celery DOT n DOT ml DOT org
To: djgpp AT delorie DOT com
Subject: Re: What is MID() macro ?
In-Reply-To: <P=v0NwHLCsw+7yJx9rf9ZESpnLc+@4ax.com>
Message-ID: <Pine.LNX.4.10.9910011531110.3813-100000@celery.n.ml.org>
MIME-Version: 1.0
Reply-To: djgpp AT delorie DOT com
X-Mailing-List: djgpp AT delorie DOT com
X-Unsubscribes-To: listserv AT delorie DOT com

On Fri, 1 Oct 1999, Kevin wrote:
) On Thu, 30 Sep 1999 00:57:43 -0700, Clemens Valens
) <c DOT valensNOc DOT SPAM AT mindless DOT com DOT invalid> wrote:
) >See allegro.h. There MID() is defined as follows:
) >#define MID(x,y,z)  MAX((x), MIN((y), (z)))
) I think I see now, it returns whichever of x, y or z is the middle
) value.
Maybe that's what it's supposed to do, but if you were to pass 3,2,1 to that
macro, it'd evaluate as follows:
	MAX(3, MIN(2, 1))
	MAX(3, 1)
	3

Passing 1,2,3 or 2,3,1 work as expected, it's just if the first argument is
the largest it will be returned instead of the middle argument.

-- 
Daniel Reed <n AT ml DOT org>
The optimist proclaims we live in the best of all possible worlds; the pessimist fears this is true. -- James B. Cabell

- Raw text -


  webmaster     delorie software   privacy  
  Copyright © 2019   by DJ Delorie     Updated Jul 2019