[postgis-devel] strange behavoir of LW_ABS

nicklas.aven at jordogskog.no nicklas.aven at jordogskog.no
Wed Sep 16 04:34:42 PDT 2009


Hallo
 
Maybe this is my lack of c-knowledge, but i'm very confused of the behavior of LW_ABS
 
The code below I thought would return -1, but i returns -3.
 
Is this expected behavior?
 
Why do we have LW_ABS() instead of fabs() ?
 

#include <stdio.h> 
#define LW_ABS(a)   ((a) < (0) ? (-a) : (a))
int main() 
{
int d,e,f;
d = 1;
e = -2;
f = LW_ABS(d+e);
printf ("%d\n",f );
return 0;
}

 
Thanks
Nicklas
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.osgeo.org/pipermail/postgis-devel/attachments/20090916/a364a588/attachment.html>


More information about the postgis-devel mailing list