Relay-Version: version B 2.10 5/3/83; site utzoo.UUCP Path: utzoo!watmath!clyde!rutgers!sri-spam!ames!ucbcad!ucbvax!decvax!mcnc!unc!steele From: steele@unc.UUCP Newsgroups: comp.lang.c Subject: Re: fabs(x) vs. (x) < 0 ? -(x) : (x) Message-ID: <756@unc.unc.UUCP> Date: Fri, 30-Jan-87 19:10:44 EST Article-I.D.: unc.756 Posted: Fri Jan 30 19:10:44 1987 Date-Received: Sat, 31-Jan-87 19:39:57 EST References: <4943@mimsy.UUCP> <2550005@hpisod2.HP> Reply-To: steele@unc.UUCP (Oliver Steele) Organization: CS Dept, U. of N. Carolina, Chapel Hill Lines: 18 In article <2550005@hpisod2.HP> decot@hpisod2.HP (Dave Decot) writes: > >You could implement fabs() as a macro as follows: > > #define fabs(X) ((_fabs = (X)), (_fabs < 0? -_fabs : _fabs)) > >if _fabs were declared as a float in the math library. Beware fabs(a,fabs(b,c)), as well as fabs(a,func(b,c)) where func is a macro which invokes fabs. -- Oliver Steele----------------------------------steele@unc "When a tree dies, ...!{decvax,ihnp4}!mcnc!unc!steele plant another in its place." steele%unc@csnet-relay.csnet