Relay-Version: version B 2.10 5/3/83; site utzoo.UUCP
Path: utzoo!mnetor!seismo!rutgers!ames!ucbcad!ucbvax!decvax!ima!haddock!karl
From: karl@haddock.UUCP (Karl Heuer)
Newsgroups: comp.lang.c
Subject: Re: fabs(x) vs. (x) < 0 ? -(x) : (x)
Message-ID: <295@haddock.UUCP>
Date: Fri, 9-Jan-87 03:46:26 EST
Article-I.D.: haddock.295
Posted: Fri Jan  9 03:46:26 1987
Date-Received: Fri, 9-Jan-87 21:38:22 EST
References: <4477@ut-ngp.UUCP>
Reply-To: karl@haddock.ISC.COM.UUCP (Karl Heuer)
Organization: Interactive Systems, Boston
Lines: 10
Summary: side effects

In article <4477@ut-ngp.UUCP> jjr@ngp.UUCP (Jeff Rodriguez) writes:
>Why isn't fabs() implemented as a macro [ (X) < 0 ? -(X) : (X) ]?

I think it's primarily because of things like "y = fabs(sin(x))", which would
be inefficent, and "y = fabs(*px++)", which would be wrong.

Generally, the standard library functions are not implemented as macros unless
they evaluate each argument exactly once.  (There are exceptions, though.)

Karl W. Z. Heuer (ima!haddock!karl or karl@haddock.isc.com), The Walking Lint