fabs(x) vs. (x) < 0 ? -(x) : (x)
steele at unc.UUCP
steele at unc.UUCP
Sat Jan 31 10:10:44 AEST 1987
In article <2550005 at hpisod2.HP> decot at 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 at unc
"When a tree dies, ...!{decvax,ihnp4}!mcnc!unc!steele
plant another in its place." steele%unc at csnet-relay.csnet
More information about the Comp.lang.c
mailing list