Relay-Version: version B 2.10 5/3/83; site utzoo.UUCP Path: utzoo!mnetor!seismo!ll-xn!nike!oliveb!sun!dgh From: dgh@sun.uucp (David Hough) Newsgroups: net.lang.c Subject: Re: Conversion, rounding, and truncation Message-ID: <8948@sun.uucp> Date: Wed, 5-Nov-86 14:44:09 EST Article-I.D.: sun.8948 Posted: Wed Nov 5 14:44:09 1986 Date-Received: Wed, 5-Nov-86 22:44:56 EST References: <797@oakhill.UUCP> <1289@ttrdc.UUCP> Organization: Sun Microsystems, Inc. Lines: 24 > pow(x,y) is basically implemented as exp(y*log(x)), > with domain and range checking too of course. > Depending on the exact implemen- > tation of exp() and log(), this can give results which are slightly off even > when an exact solution would be representable. As a > guru explained to me, this is done, even if it would be possible to special- > case exactly-integral exponents to pow(), in order to preserve the local > continuity of the function. It is true that the simplest way to implement pow(x,y) is exp(y*log(x)). That is not the best way. There is no inherent reason why x**y for small integer values x and y can not be computed correctly and without losing monotonicity. The pow() in recent Sun software releases and in 4.3 BSD works pretty well. In contrast most Unix implementations of libm functions are pretty poor - Gene Spafford (gatech!spaf) wrote a book about them. The paranoia program distributed by Richard Karpinski (ucbvax!ucsfcgl!cca.ucsf!dick) tests computer arithmetic, including pow() at small integer values. David Hough dhough@sun.com