[postgis-devel] strange behavoir of LW_ABS
Mark Cave-Ayland
mark.cave-ayland at siriusit.co.uk
Wed Sep 16 05:09:34 PDT 2009
nicklas.aven at jordogskog.no wrote:
> Yes, you are right
>
> But is this what is wanted. Why do we have that macro, is it faster than
> fabs();
>
> From your description Mark I see that putting the -sign outside the
> parenteses in the macro eliminates this risk:
> #define LW_ABS(a) ((a) < (0) ? -(a) : (a))
>
> then it works as I want :-)
>
> Or is this special behavior wanted and why the macro is there?
>
> This is no problem now when I have found why (and where) my code broke,
> but just curious.
>
> /Nicklas
I'm not sure what the origin of the macro is, so it seems that you've
found a genuine bug. However, it is likely there because one of the
platforms supported by PostgreSQL/PostGIS doesn't have fabs() - the
money is normally on Solaris/Win32 for these types of quirk...
HTH,
Mark.
--
Mark Cave-Ayland - Senior Technical Architect
PostgreSQL - PostGIS
Sirius Corporation plc - control through freedom
http://www.siriusit.co.uk
t: +44 870 608 0063
Sirius Labs: http://www.siriusit.co.uk/labs
More information about the postgis-devel
mailing list