From: Kevin Newsgroups: comp.os.msdos.djgpp Subject: Re: What is MID() macro ? Date: Fri, 01 Oct 1999 22:04:35 +0100 Message-ID: References: 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 Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit 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 wrote: >On Fri, 1 Oct 1999, Kevin wrote: >) On Thu, 30 Sep 1999 00:57:43 -0700, Clemens Valens >) 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.