[postgis-devel] Min, Max and Abs functions
TECHER Jean David
davidtecher at yahoo.fr
Thu Nov 4 02:27:22 PST 2004
Hi Marc
You're right
At the beginning of this week I've got some errors code with min, max and
abs()...
For memory for the file misures.c, I needed to put
#define max(a,b) ((a) > (b) ? (a) : (b))
#define min(a,b) ((a) <= (b) ? (a) : (b))
#define abs(a) ((a) < (0) ? (-a) : (a))
at the beginning of this file in order to solve my problem
(I am not a good programmer in C/C++ you know)
but about what you said did you have any suggestion about how to solve
problem with compilers ???
----------------------------------------------------------------
TECHER Jean David
Responsable Informatique 01MAP
e-mail: davidtecher at yahoo.fr
site perso : http://techer.pascal.free.fr/postgis/
site pro: http://www.01map.com/download/
------------------------------------------------------------
----- Original Message -----
From: "Mark Cave-Ayland" <m.cave-ayland at webbased.co.uk>
To: <postgis-devel at postgis.refractions.net>
Sent: Thursday, November 04, 2004 10:53 AM
Subject: [postgis-devel] Min, Max and Abs functions
> Hi everyone,
>
> Reading through the PostgreSQL lists a couple of days ago, I noticed a
> comment about how PostgreSQL supplies it's own min(), max(), and abs()
> functions. Surely enough, if you download a PostgreSQL source and look in
> src/include/c.h (which is included by postgres.h) you can see the
> corresponding definitions:
>
>
> /*
> * Max
> * Return the maximum of two numbers.
> */
> #define Max(x, y) ((x) > (y) ? (x) : (y))
>
> /*
> * Min
> * Return the minimum of two numbers.
> */
> #define Min(x, y) ((x) < (y) ? (x) : (y))
>
> /*
> * Abs
> * Return the absolute value of the argument.
> */
> #define Abs(x) ((x) >= 0 ? (x) : -(x))
>
>
> Is there any reason why we shouldn't use these in PostGIS? From memory,
> there are several definitions of min(), max() and abs() particularly in
the
> 0.9 branch which must be defined if using certain compilers like MingW and
> Cygwin. It strikes me that the code could be tidied up and made consistent
> across all platforms by making use of the PostgreSQL operators instead.
>
> For reference, the current CVS contains the following in liblwgeom.h:
>
> //#if ! defined(__MINGW32__)
> #define max(a,b) ((a) > (b) ? (a) : (b))
> #define min(a,b) ((a) <= (b) ? (a) : (b))
> //#endif
> #define abs(a) ((a) < (0) ? (-a) : (a))
>
> While the definitions are slightly different in the cases where equal
> numbers are involved, since the macros are #defined it should just be the
> result which is altered since none of the parameters are passed by
> reference.
>
>
> Thoughts?
>
> Mark.
>
> ------------------------
> WebBased Ltd
> South West Technology Centre
> Tamar Science Park
> Plymouth
> PL6 8BT
>
> T: +44 (0)1752 791021
> F: +44 (0)1752 791023
> W: http://www.webbased.co.uk
>
>
>
> _______________________________________________
> postgis-devel mailing list
> postgis-devel at postgis.refractions.net
> http://postgis.refractions.net/mailman/listinfo/postgis-devel
>
More information about the postgis-devel
mailing list