Computing the absolute value of an integer

Mike Mitten dsrekml at prism.gatech.EDU
Sun May 6 15:42:31 AEST 1990


In article <1990May4.121950.22726 at agate.berkeley.edu> c60c-3cf at e260-3c.berkeley.edu (Dan Kogai) writes:
>What's wrong with using a macro like the following
>
>#define abs(x) (((x) >= 0) ? (x) : -(x))

...

>	I just took a look at /usr/include/math.h and it was even more
>concice:
>
>#define _abs(x) (x < 0 ? (-x): (x))


Won't both of these macros blow up if x is a function such as:

	y = abs(foo(bar));

or

	y = _abs(foo(bar));


	Shalom,

	      -Mike
Mike  Mitten                              -- Irony is the spice of life. --
WREK Radio, Georgia Tech, Atlanta GA, 30332  (404) 894-2468
ARPA:  dsrekml at prism.gatech.edu
uucp: ...!{allegra,amd,hplabs,seismo,ut-ngp}!gatech!prism!dsrekml
| CAUTION:  The above is output of experimental software simulating the       |
|           result of 1000 monkeys typing on 1000 typewriters for 1000 years. |



More information about the Comp.lang.c mailing list