Path: utzoo!utgpu!news-server.csri.toronto.edu!mailrus!wuarchive!zaphod.mps.ohio-state.edu!samsung!emory!mephisto!prism!dsrekml From: dsrekml@prism.gatech.EDU (Mike Mitten) Newsgroups: comp.lang.c Subject: Re: Computing the absolute value of an integer Keywords: absolute, abs(), fabs() Message-ID: <8977@hydra.gatech.EDU> Date: 6 May 90 05:42:31 GMT References: <11679@june.cs.washington.edu> <1990May4.121950.22726@agate.berkeley.edu> Organization: Georgia Institute of Technology Lines: 31 In article <1990May4.121950.22726@agate.berkeley.edu> c60c-3cf@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@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. |