[Numeric-interest] fdlibm-comments from olecom at gmail.com: pow and minus infinity and more

David Hough 754R work 754r at ucbtest.org
Thu Sep 23 15:39:47 PDT 2010



Date: Mon, 23 May 2005 02:21:59 +0200
From: Oleg Verych <olecom at gmail.com>
To: fdlibm-comments at sun.com
Subject: pow and minus infinity and more

1. Please take a look at that.
      pow(-inf, 0.5) = inf
      pow(-inf, -0.5) = 0
   The result should be nan in both cases.

   fdlibm applies this set of rules for pow():
      * 17. -INF ** (anything)  = -0 ** (-anything)
   thus:
      pow(-inf, +/-0.5) === pow(-0, -/+0.5)
   applying
      * 11. -0 ** (+anything except 0, NAN, odd integer)  is +0
      * 13. -0 ** (-anything except 0, NAN, odd integer)  is +INF
   we have, what we have.

   But rule in fdlibm e_sqrt.c for sqrt() is correct:
       * sqrt(-ve) = NaN         ... with invalid signal

   Original report on glibc, but fdlibm 5.3 also has it
   <http://bugs.debian.org/cgi-bin/bugreport.cgi?bug=182574>

2. In mozilla's fdlibm (very utdated) i've found this:

#ifdef _WIN32
/* VC++ optimizer reduces y - y to 0 */ 
                    return y / y;
#else
		    return  y - y;	/* inf**+-1 is NaN */
#endif

    I'm on GNU+Linux and gcc's -ffast-math does the same, while
    "y / y" is still correct.

Any comments will be appreciated.

--
  olecom





More information about the Numeric-interest mailing list