Path: utzoo!utgpu!water!watmath!clyde!bellcore!rutgers!mailrus!cornell!uw-beaver!teknowledge-vaxc!sri-unix!quintus!ok From: ok@quintus (Richard A. O'Keefe) Newsgroups: comp.lang.c Subject: pow() Keywords: exponentiation Message-ID: <164@quintus.UUCP> Date: 11 Jul 88 01:26:36 GMT Sender: news@quintus.UUCP Reply-To: ok@quintus (Richard A. O'Keefe) Organization: Quintus Computer Systems, Inc. Lines: 15 I have received e-mail taking me to task for claiming that pow() in C is similar to ** in Fortran. My correspondent was apparently labouring under the impression that pow(x,y) was the equivalent only of REAL(x)**REAL(y). The System V Interface Definition explicitly states that pow(x, y) is valid for negative x provided that "y is an integer". Judging by the versions I have used, pow() behaves *as if* it did if there is an integer n such that (double)n == y return x**n /* e.g. pow(-2.0, 3.0) = (-2.0)**3 = -8.0 */ else return exp(log(x)*y); While I personally think this is an ugly hack and that it would have been better to have two functions, this does seem to be the way things are in UNIX. The question is: what does the dpANS say? Is this special-casing for exponents which happen to approximate integers required, forbidden, allowed?