Relay-Version: version B 2.10 5/3/83; site utzoo.UUCP
Path: utzoo!mnetor!seismo!rutgers!princeton!allegra!alice!ark
From: ark@alice.UUCP
Newsgroups: comp.lang.c
Subject: Re: fabs(x) vs. (x) < 0 ? -(x) : (x)
Message-ID: <6526@alice.uUCp>
Date: Sat, 10-Jan-87 19:41:55 EST
Article-I.D.: alice.6526
Posted: Sat Jan 10 19:41:55 1987
Date-Received: Mon, 12-Jan-87 23:14:57 EST
References: <4477@ut-ngp.UUCP> <295@haddock.UUCP>
Organization: AT&T Bell Laboratories, Liberty Corner NJ
Lines: 21

If you were doing it in C++, you could say:

	inline double fabs (double x)
		{ return x < 0? -x: x; }

and it would do the right thing, efficiently.  Moreover, you could say:

	overload abs;

	inline double abs (double x)
		{ return x < 0? -x: x; }
	inline long abs (long x)
		{ return x < 0? -x: x; }
	inline int abs (int x)
		{ return x < 0? -x: x; }
	inline float abs (float x)
		{ return x < 0? -x: x; }

and not have to remember the type of your arguments.  Generalizing
the second example above to an unbounded family of types is left
as an exercise for the reader.