Complete.Org: Mailing Lists: Archives: freeciv-dev: August 2001:
[Freeciv-Dev] Re: [PATCH] is_normal_tile function
Home

[Freeciv-Dev] Re: [PATCH] is_normal_tile function

[Top] [All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index] [Thread Index]
To: Roy Tate <roy_tate@xxxxxxxxx>
Cc: Trent Piepho <xyzzy@xxxxxxxxxxxxx>, freeciv-dev@xxxxxxxxxxx
Subject: [Freeciv-Dev] Re: [PATCH] is_normal_tile function
From: Raimar Falke <hawk@xxxxxxxxxxxxxxxxxxxxxxx>
Date: Thu, 16 Aug 2001 09:32:44 +0200
Reply-to: rf13@xxxxxxxxxxxxxxxxxxxxxx

On Wed, Aug 15, 2001 at 04:51:56PM -0700, Roy Tate wrote:
> Perhaps we should have a macro
> 
> #define RANGE_CHECK (p1, p2) ((unsigned)(p1) < (unsigned)(p2))
> 
> Then the code would be
> 
>  return RANGE_CHECK(y, map.ysize) && RANGE_CHECK(x, map.xsize);

I thought about the same.

> Although this doesn't really tell the reader that y is checked
> against map size.

Another way:

/*
 * Returns true iff n \element [min_n,max_n)
 */
#define RANGE_CHECK(min_n, n, max_n) (min_n==0?(unsigned int)n<(unsigned 
int)max_n:(n>=min_n && n<max_n))

        Raimar

-- 
 email: rf13@xxxxxxxxxxxxxxxxx
 "Premature optimization is the root of all evil."
    -- D. E. Knuth in "Structured Programming with go to Statements"


[Prev in Thread] Current Thread [Next in Thread]