[Freeciv-Dev] Re: [PATCH] is_normal_tile function
[Top] [All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index] [Thread Index]
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"
- [Freeciv-Dev] Re: [PATCH] is_normal_tile function, (continued)
- [Freeciv-Dev] Re: [PATCH] is_normal_tile function, Raimar Falke, 2001/08/15
- [Freeciv-Dev] Re: [PATCH] is_normal_tile function, Gregory Berkolaiko, 2001/08/15
- [Freeciv-Dev] Re: [PATCH] is_normal_tile function, Raimar Falke, 2001/08/15
- [Freeciv-Dev] Re: [PATCH] is_normal_tile function, Gaute B Strokkenes, 2001/08/15
- [Freeciv-Dev] Re: [PATCH] is_normal_tile function, Gregory Berkolaiko, 2001/08/16
- [Freeciv-Dev] Re: [PATCH] is_normal_tile function, Ross W. Wetmore, 2001/08/16
- [Freeciv-Dev] Re: [PATCH] is_normal_tile function, Trent Piepho, 2001/08/15
- [Freeciv-Dev] Re: [PATCH] is_normal_tile function, Tony Stuckey, 2001/08/15
- [Freeciv-Dev] Re: [PATCH] is_normal_tile function, Miguel Farah F., 2001/08/15
- [Freeciv-Dev] Re: [PATCH] is_normal_tile function, Roy Tate, 2001/08/15
- [Freeciv-Dev] Re: [PATCH] is_normal_tile function,
Raimar Falke <=
- [Freeciv-Dev] Re: [PATCH] is_normal_tile function, Ross W. Wetmore, 2001/08/16
- [Freeciv-Dev] Re: [PATCH] is_normal_tile function, Raimar Falke, 2001/08/17
- [Freeciv-Dev] Re: [PATCH] is_normal_tile function, Ross W. Wetmore, 2001/08/17
- [Freeciv-Dev] Re: [PATCH] is_normal_tile function, Raimar Falke, 2001/08/17
- [Freeciv-Dev] Re: [PATCH] is_normal_tile function, Ross W. Wetmore, 2001/08/16
- [Freeciv-Dev] Re: [PATCH] is_normal_tile function, Raimar Falke, 2001/08/17
|
|