fabs(x) vs. (x) < 0 ? -(x) : (x)

Jeff Rodriguez jjr at ut-ngp.UUCP
Thu Jan 8 02:27:56 AEST 1987


What's the difference between 
     double x, y;
     . . .
     y = fabs(x)
and
     #define abs(X) ((X) < 0 ? -(X) : (X))
     double x, y;
     . . . 
     y = abs(x);

I.e., why isn't fabs() implemented as a macro?

			Jeff Rodriguez
			jjr at ngp.utexas.edu



More information about the Comp.lang.c mailing list