delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp/1999/10/01/19:32:53

From: Kevin <krugman AT nospam DOT demon DOT co DOT uk>
Newsgroups: comp.os.msdos.djgpp
Subject: Re: What is MID() macro ?
Date: Fri, 01 Oct 1999 22:04:35 +0100
Message-ID: <hyD1N3ucPeEqcCdf0tZvoTvak07Y@4ax.com>
References: <P=v0NwHLCsw+7yJx9rf9ZESpnLc+@4ax.com> <Pine DOT LNX DOT 4 DOT 10 DOT 9910011531110 DOT 3813-100000 AT celery DOT n DOT ml DOT org>
NNTP-Posting-Host: reality-bytes.demon.co.uk
X-NNTP-Posting-Host: reality-bytes.demon.co.uk:212.228.30.60
X-Trace: news.demon.co.uk 938811947 nnrp-04:26638 NO-IDENT reality-bytes.demon.co.uk:212.228.30.60
X-Complaints-To: abuse AT demon DOT net
X-Newsreader: Forte Agent 1.6/32.525
MIME-Version: 1.0
Lines: 37
To: djgpp AT delorie DOT com
DJ-Gateway: from newsgroup comp.os.msdos.djgpp
Reply-To: djgpp AT delorie DOT com

On Fri, 1 Oct 1999 16:20:23 -0400 (EDT), Daniel Reed
<djr AT narnia DOT n DOT ml DOT org> wrote:

>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.


Shawn himself (we're not worthy, we're not worthy) has cleared this up
in a later posting and sais words to the effect of

using MID(x, y, z)

x should be less than z.
if y is less than x, x will be returned
if y is greater than z, z will be returned.
if y > x and y < z, y will be returned.

it limits the range of values reeturned to between x and z

at least that's my understanding of it.

Kevin.

Thankyou Shawn.

- Raw text -


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