Relay-Version: version B 2.10 5/3/83; site utzoo.UUCP Path: utzoo!watmath!clyde!rutgers!princeton!allegra!ulysses!faline!sabre!zeta!mb2c!edsdrd!edstb!msudoc!umich!jtr485 From: jtr485@umich.UUCP Newsgroups: comp.lang.c Subject: Re: fabs(x) vs. (x) < 0 ? -(x) : (x) Message-ID: <81@umich.UUCP> Date: Thu, 19-Feb-87 09:58:35 EST Article-I.D.: umich.81 Posted: Thu Feb 19 09:58:35 1987 Date-Received: Sat, 21-Feb-87 20:07:32 EST References: <4943@mimsy.UUCP> <2550005@hpisod2.HP> <628@sdchema.sdchem.UUCP> <1070@dg_rtp.UUCP> Distribution: world Organization: EECS, University of Michigan Lines: 18 In article <1070@dg_rtp.UUCP>, meissner@dg_rtp.UUCP writes: > > #define fabs(X) (((_fabs = (X)) < 0? -_fabs : _fabs)) > It may solve that problem, but: > fabs( fabs( y ) - 10.0 ) > would still get the wrong answer. > Michael Meissner No. This will still get the right answer. The only thing to ever worry about would be a side effect explicitly manipulating _fabs. Such as: fabs( _fabs++ ) which expands to: (((_fabs = (_fabs++)) < 0? -_fabs : _fabs)) And now there is no way of knowing when the ++ gets done relative to the expressions after the '?'. But only direct manipulation of the 'hidden' variable can do this. --j.a.tainter